Last active
January 4, 2016 20:10
-
-
Save ncherro/8672609 to your computer and use it in GitHub Desktop.
upstart script for nginx
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
# save to /etc/init/nginx.conf and chmod +x on a Ubuntu server with upstart | |
# | |
# start with `sudo service nginx start` | |
# stop with `sudo service nginx stop` | |
# | |
# DAEMON is the full path to the nginx binary. in this case, nginx | |
# was installed with passenger - passenger-install-nginx-module | |
# | |
# PIDFILE is the full path to the nginx pidfile, defined with the pid | |
# directive in nginx.conf http://wiki.nginx.org/CoreModule#pid | |
description "nginx http daemon" | |
author "Nick Herro <ncherro@gmail.com>" | |
start on (filesystem and net-device-up IFACE=lo) | |
stop on runlevel [!2345] | |
env DAEMON=/opt/nginx/sbin/nginx | |
env PIDFILE=/var/run/nginx/nginx.pid | |
expect fork | |
respawn | |
respawn limit 10 5 | |
# ensure there are no errors with nginx config | |
pre-start exec $DAEMON -t | |
# upstart will be tracking the wrong PID after forking, so check our $PIDFILE | |
post-stop exec start-stop-daemon --stop --pidfile $PIDFILE --name nginx --exec $DAEMON --signal QUIT | |
exec $DAEMON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment