Last active
March 8, 2017 12:37
-
-
Save stuzart/3169625 to your computer and use it in GitHub Desktop.
Simple init.d script for delayed_job
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/sh | |
# upstart-job | |
# | |
# Symlink target for initscripts that have been converted to Upstart. | |
set -e | |
APP_PATH="/srv/rails/seek" | |
start_job() { | |
echo "Starting delayed job" | |
sudo -iu www-data bash -c "cd $APP_PATH && RAILS_ENV=production ./script/delayed_job start" | |
} | |
stop_job() { | |
echo "Stopping delayed job" | |
sudo -iu www-data bash -c "cd $APP_PATH && RAILS_ENV=production ./script/delayed_job stop" | |
} | |
COMMAND="$1" | |
shift | |
case $COMMAND in | |
status) | |
;; | |
start|stop|restart) | |
$ECHO | |
if [ "$COMMAND" = "stop" ]; then | |
stop_job | |
elif [ "$COMMAND" = "start" ]; then | |
start_job | |
elif [ "$COMMAND" = "restart" ]; then | |
stop_job | |
sleep 1s | |
start_job | |
exit 0 | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment