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
In your composer.json
add the requirement
"require": {
"corley/maintenance-bundle": "0.1.*"
}
Register the bundle in your AppKernel
public function registerBundles()
{
...
$bundles = array(
...
new Corley\MaintenanceBundle\CorleyMaintenanceBundle(),
);
...
return $bundles;
}
When you want to put your web application under maintenance
app/console corley:maintenance:lock on
Restore the application status
app/console corley:maintenance:lock off
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.
In order to obtain your configuration options just use the console
app/console corley:maintenance:apache-dump
app/console corley:maintenance:nginx-dump
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 pagesymlink
If you want to use symlinks instead hardcopy strategyhard_lock
Is the name used in order to lock the websiteweb
public folder (by defaultweb
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 lockips
A list of ips that skip the maintenance lock
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.