Skip to content

Instantly share code, notes, and snippets.

@rrichards
Forked from srpouyet/nginx.conf
Created January 6, 2014 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rrichards/8289549 to your computer and use it in GitHub Desktop.
Save rrichards/8289549 to your computer and use it in GitHub Desktop.
### Nginx upstart script
### source: http://serverfault.com/a/391737/70451
### /etc/init/nginx.conf
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/local/sbin/nginx
env PIDFILE=/var/run/nginx.pid
# Needed to allow Nginx to start, however, the wrong PID will be tracked
expect fork
# Test the nginx configuration (Upstart will not proceed if this fails)
pre-start exec $DAEMON -t
# Ensure nginx is shutdown gracefully
# Upstart will be tracking the wrong PID so the following is needed to stop nginx
post-stop exec $DAEMON -s stop
# Start Nginx
exec $DAEMON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment