-
-
Save raecoo/6eeb472e7b8bd8213785 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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