Merge branch 'cc-5709-airtime-analyzer' of github.com:sourcefabric/Airtime into cc-5709-airtime-analyzer

This commit is contained in:
Albert Santoni 2014-04-24 17:06:00 -04:00
commit ce9b9c7314
5 changed files with 41 additions and 0 deletions

View file

@ -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());
}
}

View file

@ -18,4 +18,9 @@ class IndexController extends Zend_Controller_Action
$this->_helper->layout->setLayout('layout');
}
public function maintenanceAction()
{
$this->getResponse()->setHttpResponseCode(503);
}
}

View file

@ -17,6 +17,14 @@ class UpgradeController extends Zend_Controller_Action
return;
}
//Disable Airtime UI
//create a temporary maintenance notification file
//when this file is on the server, zend framework redirects all
//requests to the maintenance page and sets a 503 response code
$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 +83,11 @@ class UpgradeController extends Zend_Controller_Action
$file = new SplFileObject($iniFile, "w");
$file->fwrite($beginning."\n".$newLines.$end);
//delete maintenance.txt to give users access back to Airtime
unlink($maintenanceFile);
//TODO: clear out the cache
$this->getResponse()
->setHttpResponseCode(200)
->appendBody("Upgrade to Airtime 2.5.3 OK");

View 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);
}
}
}

View file

@ -0,0 +1 @@
Airtime is down for maintenance. We'll be back soon!