Last active
August 29, 2015 14:05
-
-
Save zhangalex/e5b840bbb8293c2841b2 to your computer and use it in GitHub Desktop.
clockwork init script
This file contains 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/sh | |
### BEGIN INIT INFO | |
# Provides: clock | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts clock for wand | |
# Description: starts clock for wand | |
### END INIT INFO | |
AS_USER="wand" | |
PID_FILE=/opt/active/wand.theactivenetwork.cn/shared/pids/cw.pid | |
APP_PATH=/opt/active/wand.theactivenetwork.cn/current | |
BUNDLE_PATH=/home/wand/.rvm/wrappers/ruby-2.0.0-p481/bundle | |
CMD1="cd ${APP_PATH}; RAILS_ENV=cloud_production ${BUNDLE_PATH} exec clockwork clock.rb -e cloud_production >> log/clockwork.log 2>&1 &" | |
case $1 in | |
start) | |
kill -9 `cat $PID_FILE` || true | |
sudo -H -u $AS_USER bash -c "$CMD1" | |
ps -eo pid,command | grep clockwork | grep -v grep | awk '{print $1}' > $PID_FILE | |
;; | |
stop) | |
kill -9 `cat $PID_FILE` || true | |
;; | |
restart) | |
kill -9 `cat $PID_FILE` || true | |
sudo -H -u $AS_USER bash -c "$CMD1" | |
ps -eo pid,command | grep clockwork | grep -v grep | awk '{print $1}' > $PID_FILE | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment