Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I come from a .NET background and there are many things I loved about it along side many things I hated. IIS was, in general, one of those things I hated.

However, one really nice feature of IIS was that you could put a "drain stop" on your server node. This would redirect all new traffic to other nodes but allow users currently online to finish out their sessions before shutting down IIS completely.

This was exceptionally handy for doing deployments without interrupting user sessions.

At my new company, we're not .NET and loving it. We're working in JRuby and Java on EC2 using Apache as a front-end and Tomcat as our back-end.

Has anyone ever run across any solution that provides similar functionality with Tomcat, Nginx, or Apache?

I've done some searching but was unable to come up with anything useful. How about Axis2? Does anyone have any experience with that?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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. "

share|improve this answer
    
Thanks. This looks perfect. –  Brandon Black Mar 21 '11 at 21:14

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.