Created
January 17, 2016 15:35
-
-
Save delbetu/c5b3c4f672077f1fafc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function start_if_not_running { | |
service_name=$1 | |
mypid=$(pgrep $service_name) | |
if [[ ! -n $mypid ]]; then | |
$service_name > log/$service_name.log 2>&1 & | |
mypid=$! | |
fi | |
echo $service_name $mypid | |
} | |
function start() { | |
echo dir $(pwd) | |
start_if_not_running 'mysqld' | |
start_if_not_running 'memcached' | |
start_if_not_running 'redis-server' | |
start_if_not_running 'mailcatcher' | |
if [ ! -f config/development.sphinx.conf ]; then | |
bundle exec rake ts:config | |
fi | |
if [[ -n $(pgrep 'redis-server') ]]; then | |
bundle exec sidekiq & | |
fi | |
if [[ -n $(pgrep 'memcached') && -n $(pgrep 'mysqld') ]]; then | |
bundle exec rake ts:start | |
bundle exec rake sunspot:solr:start | |
bundle exec rake sunspot:solr:start RAILS_ENV=test | |
fi | |
} | |
function stop() { | |
bundle exec rake sunspot:solr:stop | |
bundle exec rake sunspot:solr:stop RAILS_ENV=test | |
bundle exec rake ts:stop | |
ps x | grep sidekiq | awk '{print kill -9 $1}' | |
ps x | grep mailcatcher | awk '{print kill -9 $1}' | |
ps x | grep redis-server | awk '{print kill -9 $1}' | |
ps x | grep memcached | awk '{print kill -9 $1}' | |
ps x | grep mysqld | awk '{print kill -9 $1}' | |
} | |
function main() { | |
cd $RAILS_HOME | |
echo 'Run this script from your rails home' | |
echo 'You are running from ' $(pwd) | |
if [[ $1 == 'start' ]]; then | |
echo 'starting' | |
start | |
elif [[ $1 == 'stop' ]]; then | |
echo 'stopping' | |
stop | |
else | |
echo 'Only start/stop options are allowed' | |
fi | |
} | |
RAILS_HOME=. | |
main $1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment