Ubuntu Upstart¶
Legacy
Upstart is legacy. Modern Ubuntu uses systemd. See Systemd.
Upstart Configuration¶
Save as /etc/init/nginx.conf:
# nginx
description "nginx http daemon"
author "George Shammas <[email protected]>"
start on (filesystem and net-device-up IFACE!=lo)
stop on runlevel [!2345]
env DAEMON=/usr/sbin/nginx
env PID=/var/run/nginx.pid
expect fork
respawn
respawn limit 10 5
pre-start script
$DAEMON -t
if [ $? -ne 0 ]
then exit $?
fi
end script
exec $DAEMON
Commands¶
Reload configuration:
initctl reload-configuration
Check status:
initctl list | grep nginx
Start NGINX:
initctl start nginx
Configuration Notes¶
respawn- Keeps NGINX master process aliveexpect fork- Tracks NGINX after forkingrespawn limit 10 5- Stop if respawned >10 times in 5 secondspre-start script- Tests config before starting