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.2.*"
}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
bin/console corley:maintenance:lock onRestore the application status
bin/console corley:maintenance:lock offIf 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
bin/console corley:maintenance:dump-apachebin/console corley:maintenance:dump-nginxYou 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: falseOptions:
pageis the original maintenance pagesymlinkIf you want to use symlinks instead hardcopy strategyhard_lockIs the name used in order to lock the websitewebpublic folder (by defaultwebfolder)soft_lockIs the name used in order to lock the website (using app layer)whilelistAuthorized connections [soft-lock only]pathsA list of paths that skip the maintenance lockipsA 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.
When you want to put your web application under maintenance using a soft-locking strategy:
bin/console corley:maintenance:soft-lock onRestore the application status
bin/console corley:maintenance:soft-lock off