Skip to content

Instantly share code, notes, and snippets.

@jgeiger
Created August 13, 2014 21:32
Show Gist options
  • Save jgeiger/1ef273fae732ed619e39 to your computer and use it in GitHub Desktop.
Save jgeiger/1ef273fae732ed619e39 to your computer and use it in GitHub Desktop.
nginx upstart config
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/local/nginx/sbin/nginx
env PIDFILE=/usr/local/nginx/logs/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 start-stop-daemon --stop --pidfile $PIDFILE --name nginx --exec $DAEMON --signal QUIT
# Start Nginx
exec $DAEMON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment