Skip to content

Instantly share code, notes, and snippets.

@zhangalex
Last active August 29, 2015 14:05
Show Gist options
  • Save zhangalex/3093ebcc0135ac5b883c to your computer and use it in GitHub Desktop.
Save zhangalex/3093ebcc0135ac5b883c to your computer and use it in GitHub Desktop.
sidekiq init scripts
#!/bin/sh
### BEGIN INIT INFO
# Provides: sidekiq
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts sidekiq for event mobile
# Description: starts sidekiq for event mobile
### END INIT INFO
AS_USER="wand"
PID_FILE=/opt/active/eventmobile.theactivenetwork.cn/shared/pids/sidekiq.pid
APP_PATH=/opt/active/eventmobile.theactivenetwork.cn/current
BUNDLE_PATH=/home/wand/.rvm/wrappers/ruby-2.0.0-p481/bundle
CMD="cd ${APP_PATH}; RAILS_ENV=production ${BUNDLE_PATH} exec sidekiq -d -L $APP_PATH/log/sidekiq.log -P $PID_FILE"
case $1 in
start)
kill -9 `cat $PID_FILE` || true
sudo -H -u $AS_USER bash -c "$CMD"
;;
stop)
kill -9 `cat $PID_FILE` || true
;;
restart)
kill -9 `cat $PID_FILE` || true
sudo -H -u $AS_USER bash -c "$CMD"
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment