Skip to content

Instantly share code, notes, and snippets.

@alexander-ae
Created August 13, 2014 21:16
Show Gist options
  • Save alexander-ae/ab137d8b7b6b37e5a5a1 to your computer and use it in GitHub Desktop.
Save alexander-ae/ab137d8b7b6b37e5a5a1 to your computer and use it in GitHub Desktop.
Webfaction: supervisord + nginx
*/1 * * * * /home/{user}/webapps/{app}/nginx/sbin/nginx -c /home/{user}/webapps/{app}/nginx/conf/nginx.conf >> $HOME/tmp/cron.log 2>&1 ;
*/1 * * * * cd /home/{user}/bin/supervisord; /home/{user}/etc/supervisord.sh start >> $HOME/tmp/cron.log 2>&1 ;
#! /bin/bash
PS=supervisord
SUPERVISORD=/home/{user}/bin/supervisord
SUPERVISORCTL=/home/{user}/bin/supervisorctl
PIDFILE=/home/{user}/tmp/supervisord.pid
OPTS="-c /home/{user}/etc/supervisord.conf"
TRUE=1
FALSE=0
test -x $SUPERVISORD || exit 0
log() {
echo $(date -R): ${1}
}
isRunning() {
if [ "$(ps -p `cat ${PIDFILE}` | wc -l)" -gt 1 ]; then
return 1
else
log "Supervisor not already running."
return 0
fi
}
start () {
log "Checking Supervisor status."
isRunning
isAlive=$?
if [ "${isAlive}" -eq $TRUE ]; then
log "Supervisor is already running."
else
log "Starting Supervisor daemon."
$SUPERVISORD $OPTS || log "Failed!"
fi
}
stop () {
log "Stopping Supervisor daemon."
$SUPERVISORCTL $OPTS shutdown || log "Failed!"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment