I do not know what
/etc/init.d/nginx in Ubuntu does, but I can explain what mechanisms Nginx has so that you can upgrade it without interrupting service.
If you'd install/upgrade Nginx from the sources, you'd certainly build it at the first. Then you issue
make install to copy new binary.
Then, you have to learn what is PID of Nginx "master" process:
ps ax | grep nginx
and find "master" process PID in the output. Let's assume it's 123.
USR2 signal to the master process:
kill -USR2 123
You can review Nginx's
error.log and the list of processses (
ps ax | grep nginx) to make sure that a new instance of Nginx has started.
kill -WINCH 123
Now the new Nginx instance will get requests. And the old worker processes shutdown gracefully. Again, review
error.log to make sure everything goes fine.
kill -QUIT 123
will shutdown old Nginx master. After that, your system has new Nginx installed and running.
This procedure ensures all the connections are served without interruptions.