Is there a Apache or Nginx equivalent to the IIS "drain stop"?

If you want to shutdown the local apache site letting the current users finish their current task do a graceful Apache stop. I'll presume that you have some other architecture that would redirect users to another operational website to allow them to continue (i.e. load balancer, etc).

From the Apache site:

Signal: WINCH apachectl -k graceful-stop

" The WINCH or graceful-stop signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything). The parent will then remove its PidFile and cease listening on all ports. The parent will continue to run, and monitor children which are handling requests. Once all children have finalised and exited or the timeout specified by the GracefulShutdownTimeout has been reached, the parent will also exit. If the timeout is reached, any remaining children will be sent the TERM signal to force them to exit.

A TERM signal will immediately terminate the parent process and all children when in the "graceful" state. However as the PidFile will have been removed, you will not be able to use apachectl or httpd to send this signal. "


In practice, simply

apache2ctl graceful

will gracefully restart apache process allowing it to load a new configuration

Here for example, lets say you have in production www.v1 and dev in www.v2

<VirtualHost *:80>
    ServerName www.example.com

    DocumentRoot /var/www/vhosts/example.com/www.v1
    [...]
</VirtualHost>

<VirtualHost *:80>
    ServerName dev.exemple.com

    DocumentRoot /var/www/vhosts/example.com/www.v2
    [...]
</VirtualHost>

Now ready for putting dev in production? Edit configuration (nothing will change online untill you do a apache restart/graceful better watch when your logrotate takes place, it will throw a "apache2ctl graceful" )

<VirtualHost *:80>
    ServerName old.example.com

    DocumentRoot /var/www/vhosts/example.com/www.v1
    [...]
</VirtualHost>

<VirtualHost *:80>
    ServerName www.exemple.com

    DocumentRoot /var/www/vhosts/example.com/www.v2
    [...]
</VirtualHost>

When you feel everything is ready... cross your fingers that your new version works on the new domain name ;)

apache2ctl graceful

And the magi should happen :)

note that "apache2ctl graceful" automatically does a "apache2ctl configtest" and wont crash if you make an obvious mistake in your apache configuration