Skip to content

Instantly share code, notes, and snippets.

@imkarthikk
Forked from ponchik/sidekiq.sh
Last active October 12, 2017 19:43
Show Gist options
  • Save imkarthikk/2888365a9ca18da66068 to your computer and use it in GitHub Desktop.
Save imkarthikk/2888365a9ca18da66068 to your computer and use it in GitHub Desktop.
#!/bin/bash
SCRIPT='cd /web/vcms/; bundle exec sidekiq'
RUNAS=dimon
NAME=vcms-sidekiq
PIDFILE=/web/vcms/tmp/pids/sidekiq.pid
LOGFILE=/web/vcms/log/sidekiq.log
start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
exit 1
fi
echo 'Starting service...' >&2
cd /web/vcms; sidekiq -d -e production &
}
stop() {
sidekiqctl stop $PIDFILE
}
status() {
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=$(cat $PIDFILE)
if [ -z "$(ps axf | grep ${PID} | grep -v grep)" ]; then
printf "%s\n" "The process appears to be dead but pidfile still exists"
else
echo "Running, the PID is $PID"
fi
else
printf "%s\n" "Service not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment