CC-5814: 'Down for maintenance' page during upgrades
This commit is contained in:
parent
069ebd3991
commit
f536a7b1b4
5 changed files with 36 additions and 0 deletions
|
@ -16,6 +16,7 @@ require_once "Database.php";
|
|||
require_once "Timezone.php";
|
||||
require_once __DIR__.'/forms/helpers/ValidationTypes.php';
|
||||
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
|
||||
require_once __DIR__.'/controllers/plugins/Maintenance.php';
|
||||
|
||||
require_once (APPLICATION_PATH."/logging/Logging.php");
|
||||
Logging::setLogPath('/var/log/airtime/zendphp.log');
|
||||
|
@ -198,5 +199,11 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
'action' => 'password-change',
|
||||
)));
|
||||
}
|
||||
|
||||
public function _initPlugins()
|
||||
{
|
||||
$front = Zend_Controller_Front::getInstance();
|
||||
$front->registerPlugin(new Zend_Controller_Plugin_Maintenance());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,9 @@ class IndexController extends Zend_Controller_Action
|
|||
$this->_helper->layout->setLayout('layout');
|
||||
}
|
||||
|
||||
public function maintenanceAction()
|
||||
{
|
||||
$this->getResponse()->setHttpResponseCode(503);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,12 @@ class UpgradeController extends Zend_Controller_Action
|
|||
return;
|
||||
}
|
||||
|
||||
//Disable Airtime UI
|
||||
//create a temporary maintenance notification file
|
||||
$maintenanceFile = '/tmp/maintenance.txt';
|
||||
$file = fopen($maintenanceFile, 'w');
|
||||
fclose($file);
|
||||
|
||||
//Begin upgrade
|
||||
$filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
||||
$values = parse_ini_file($filename, true);
|
||||
|
@ -75,6 +81,8 @@ class UpgradeController extends Zend_Controller_Action
|
|||
$file = new SplFileObject($iniFile, "w");
|
||||
$file->fwrite($beginning."\n".$newLines.$end);
|
||||
|
||||
unlink($maintenanceFile);
|
||||
|
||||
$this->getResponse()
|
||||
->setHttpResponseCode(200)
|
||||
->appendBody("Upgrade to Airtime 2.5.3 OK");
|
||||
|
|
15
airtime_mvc/application/controllers/plugins/Maintenance.php
Normal file
15
airtime_mvc/application/controllers/plugins/Maintenance.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
class Zend_Controller_Plugin_Maintenance extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
protected $maintenanceFile = '/tmp/maintenance.txt';
|
||||
|
||||
public function preDispatch(Zend_Controller_Request_Abstract $request) {
|
||||
if (file_exists($this->maintenanceFile)) {
|
||||
$request->setModuleName('default')
|
||||
->setControllerName('index')
|
||||
->setActionName('maintenance')
|
||||
->setDispatched(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Airtime is down for maintenance. We'll be back soon!
|
Loading…
Add table
Add a link
Reference in a new issue