After upgrading your web server you need to restart it, but how is this done correctly? Just killing the server would interrupt all connections and that could cause problems such as inconsistent data and angry users. So what we need to do is to restart the web server gracefully so that all connections being served can finish. Once all connections are closed, the server restarts.
This graceful restart is already implemented in many init scripts. For instance
to restart Apache gracefully or
to restart Lighttpd. But this might not be available on all distributions. Therefore, we want to restart our server manually.
For graceful Apache restart we use
apache2ctl, which is shipped alongside Apache. To restart, run
Instead of using
apache2ctl, you might also send a signal (SIGUSR1) to the Apache parent process:
kill -USR1 `cat /var/run/apache2.pid`
Apache also supports a graceful stop if you want to shut down the server instead of restarting it:
As an alternative you may send the signal
SIGWINCH. Note that the Apache manual still documents
apachectl instead of
apache2ctl, but you should go with
apache2ctl as it has been renamed.
To do a manual graceful restart of Lighttpd, send the parent process a
SIGINT and then restart.
kill -INT `cat /var/run/lighttpd.pid` ; \ lighttpd -f /etc/lighttpd/lighttpd.conf
Read more about graceful restart: