/etc/init.d/ centos/amazonlinux
#!/bin/sh | |
# chkconfig: 2345 90 10 | |
# description: sidekiq system status | |
NAME="sidekiq" | |
ROOT_DIR="/var/www/sidekiq" | |
PID="/var/www/sidekiq/tmp/pids/sidekiq.pid" | |
CONF="/var/www/sidekiq/config/sidekiq.yml" | |
CMD="/usr/local/rbenv/shims/bundle exec sidekiq -C ${CONF} -d" | |
start() | |
{ | |
if [ -e ${PID} ]; then | |
echo "${NAME} already started" | |
exit 1 | |
fi | |
echo "start ${NAME}" | |
cd ${ROOT_DIR} | |
$CMD | |
} | |
stop() | |
{ | |
if [ ! -e ${PID} ]; then | |
echo "${NAME} not started" | |
exit 1 | |
fi | |
echo "stop ${NAME}" | |
kill -QUIT $(cat ${PID}) | |
rm -f ${PID} | |
} | |
force_stop() | |
{ | |
if [ ! -e ${PID} ]; then | |
echo "${NAME} not started" | |
exit 1 | |
fi | |
echo "stop ${NAME}" | |
kill -INT $(cat ${PID}) | |
rm -f ${PID} | |
} | |
reload() | |
{ | |
if [ ! -e ${PID} ]; then | |
echo "${NAME} not started" | |
start | |
exit 0 | |
fi | |
echo "reload ${NAME}" | |
kill -HUP `cat ${PID}` | |
} | |
restart() | |
{ | |
stop | |
start | |
} | |
status() { | |
if [ -e ${PID} ] | |
then | |
echo -n "${NAME} is running: " | |
else | |
echo -n "${NAME} is not running: " | |
fi | |
echo | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
force-stop) | |
force_stop | |
;; | |
reload) | |
reload | |
;; | |
restart) | |
restart | |
;; | |
status) | |
status | |
;; | |
*) | |
echo "Usage: $0 {start|stop|force-stop|reload|restart|status}" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment