3

I'm using the following Upstart script to keep Nginx up and running on Ubuntu server:

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]

env DAEMON=/usr/sbin/nginx
env CONF=/etc/nginx/nginx.conf

respawn
respawn limit 10 5

pre-start script
    $DAEMON -t
    if [ $? -ne 0 ]; then
            exit $?
    fi
end script

exec $DAEMON -c $CONF -g "daemon off;" > /dev/null 2>&1

This script works fine except when I'm killing the Nginx master process using the kill command. After killing the master process /var/run/nginx.pid remains the same but Nginx pid keeps changing every few seconds (this means Nginx is restarting all the time?). Any idea how to fix this?

perak
  • 1,310
  • 5
  • 20
  • 31

0 Answers0