Skip to content

Instantly share code, notes, and snippets.

@samuels410
Forked from stuzart/gist:3169625
Last active October 8, 2015 10:59
Show Gist options
  • Save samuels410/671a027f23080ec74a62 to your computer and use it in GitHub Desktop.
Save samuels410/671a027f23080ec74a62 to your computer and use it in GitHub Desktop.
#!/bin/sh
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
APP_PATH="/var/deploy/app/current"
start_job() {
echo "Starting delayed job"
sudo -iu canvasuser bash -c "cd $APP_PATH && RAILS_ENV=production ./bin/delayed_job start"
}
stop_job() {
echo "Stopping delayed job"
sudo -iu canvasuser bash -c "cd $APP_PATH && RAILS_ENV=production ./bin/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