Skip to content

Instantly share code, notes, and snippets.

@ponchik
Created April 16, 2015 10:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ponchik/9c3d9c646e19c661e162 to your computer and use it in GitHub Desktop.
Save ponchik/9c3d9c646e19c661e162 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