# Nginx and upstart

**URL:** <https://www.ruby-forum.com/t/nginx-and-upstart/227912>\
**Category:** NGINX\
**Created:** [April 3, 2013, 6:22pm UTC](https://www.ruby-forum.com/t/nginx-and-upstart/227912 "2013-04-03T18:22:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![skrode](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@skrode](https://www.ruby-forum.com/u/skrode)\
**Post date:** [April 3, 2013, 6:22pm UTC](https://www.ruby-forum.com/t/nginx-and-upstart/227912/1 "2013-04-03T18:22:39Z")

</div>

Hi

I’m using the following script to keep nginx up and running:

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

env DAEMON=/usr/sbin/nginx  
env CONF=/etc/nginx/nginx.conf  
env PID=/var/run/nginx.pid

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

It works fine except if I kill the master process with eg. kill -5. If I  
kill it with kill command the pid keeps changing every few seconds. Any  
idea  
how to fix this?

Posted at Nginx Forum:

> **[Nginx and upstart](https://forum.nginx.org/read.php?2,238036,238036#msg-238036)**
>
> Hi I'm using the following script to keep nginx up and running: start on (filesystem and net-device-up IFACE=lo) stop on runlevel \[!2345\] env DAEMON=/usr/sbin/nginx env CONF=/etc/nginx/nginx.conf env PID=/var/run/nginx.pid
