Skip to content

Instantly share code, notes, and snippets.

@8parth
Created February 19, 2019 11:13
Show Gist options
  • Save 8parth/17fbe0f49ac3fb10a4ddc77494605ca8 to your computer and use it in GitHub Desktop.
Save 8parth/17fbe0f49ac3fb10a4ddc77494605ca8 to your computer and use it in GitHub Desktop.
Resque start and stop commands
#!/bin/bash -ex
echo "stop running resque processes"
pidfile_sched="tmp/pids/resque_scheduler.pid"
if [ -e $pidfile_sched ] ; then
scheduler_pid=$(cat $pidfile_sched)
echo "scheduler_pid: $scheduler_pid"
if [ -z $scheduler_pid ] ; then
echo "No PID found for resque scheduler"
else
kill -s QUIT $scheduler_pid > /dev/null 2>&1
rm $pidfile_sched
echo "resque scheduler with pid:$scheduler_pid stopped"
fi;
else
echo "Resque scheduler pid file not found."
fi;
if [ -e 'tmp/pids/resque_work_1.pid' ]; then
for element in $(ls -d tmp/pids/resque_work*.pid)
do
echo "element: $element"
pid=$(cat $element)
echo "pid $pid"
if [ -z $pid ] ; then
echo "Resque process PID not found."
else
kill -s QUIT $pid
rm -f $element > /dev/null 2>&1
echo "Resque worker with pid:${pid} stopped"
fi;
done
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment