IndexCookbook

Cookbook: Maintenance

This recipe will show how to seamlessly switch the webserver to maintenance mode. By that it is understood that no existing connections should be interrupted, but new connections should be notified of the situation. This could be done serving some generic static content.

All this is easily achieved by Cherokee thanks to its Zero Downtime mechanism.

We will be showing a couple of use cases. The first one is mostly to illustrate the general process and will be set to serve a custom HTTP Error. It is very simple and straightforward, but is also pretty useless in a production environment. The second use case will be more advanced. It will be useful to serve a static maintenance message to the public while the administrator will retain the ability to see the actual changes.

Basic Example

The steps are fairly simple:

This can be done from the SAVE dialog. By doing this, the existing connections to the original virtual host will be preserved and will eventually end upon completion. At the same time, new requests will be delivered to its copycat and will be handled according to its specified behavior. If you don’t want this behavior you can always make a hard restart, effectively shutting down every existing connection.

By now you are almost done. Now you can make whatever changes were needed to the original host without affecting the incoming connections.

Remember to reverse the process once you are done. You’ll only have to delete the copycat or position it below the real virtual host.

Advanced Example: Static message

This set up will result in every request being redirected to the maintenance directory.

Advanced Example: Staff review

By now you should be able of switching the server to and from maintenance mode.

The next essential feature needed is to allow specific users to be able to access the original site, not the maintenance version, so that they can view the changes reflected while they are working.

The tweaking here has to take place in the original virtual server. The steps are also fairly simple.