Developed with love by KnpLabs Hire us for your project!
0

CorleyMaintenanceBundle

by wdalmut

Maintenance web pages (Hard and Soft modes) - Symfony2 Bundle

Corley Maintenance Bundle

Just an unified way to put a web application under maintenance mode using web server strategies. The maintenance
mode will cut off all requests and it will replies with a static html file and a 503 header (Service Unavailable).

Those conditions will ensure that a load balancer cut an instance off during a maintenance

Build Status

Install

In your composer.json add the requirement

"require": {
    "corley/maintenance-bundle": "0.2.*"
}

Register the bundle in your AppKernel

public function registerBundles()
{
    ...
    $bundles = array(
        ...
        new Corley\MaintenanceBundle\CorleyMaintenanceBundle(),
    );
    ...
    return $bundles;
}

Maintenance mode

When you want to put your web application under maintenance

bin/console corley:maintenance:lock on

Restore the application status

bin/console corley:maintenance:lock off

Configure your web server

If you use Apache2 you have to add few lines to your .htaccess, in case of nginx just add dedicated
lines to web app configuration.
Make sure that those lines precede any other rewrite rule.
The mod_rewrite module in Apache2 has to be installed and enabled.

In order to obtain your configuration options just use the console

Apache2

bin/console corley:maintenance:dump-apache

Nginx

bin/console corley:maintenance:dump-nginx

Configuration

You can configure the bundle in order to change the default behaviour (all options has a default value)

# config.yml
corley_maintenance:
    page: %kernel.root_dir%/../web/maintenance.dist.html
    hard_lock: lock.html
    symlink: false

Options:

  • page is the original maintenance page
  • symlink If you want to use symlinks instead hardcopy strategy
  • hard_lock Is the name used in order to lock the website
  • web public folder (by default web folder)
  • soft_lock Is the name used in order to lock the website (using app layer)
  • whilelist Authorized connections [soft-lock only]
    • paths A list of paths that skip the maintenance lock
    • ips A list of ips that skip the maintenance lock

Soft locking

The soft locking strategy use the php layer in order to lock down the website. This means that the
application must works in order to lock down the web site.

The soft lock runs at kernel.request and stop other event propagations.

When you want to put your web application under maintenance using a soft-locking strategy:

bin/console corley:maintenance:soft-lock on

Restore the application status

bin/console corley:maintenance:soft-lock off
The MIT License (MIT)

Copyright (c) <2014> <Walter Dal Mut>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
corley_maintenance:
page: /home/knpbundles/sites/KnpBundles-prod/repositories/wdalmut/CorleyMaintenanceBundle/DependencyInjection/../Resources/views/maintenance.html
web: %kernel.root_dir%/../web
soft_lock: soft.lock
hard_lock: hard.lock
symlink: false
whitelist:
paths: Array
ips: Array