raugfer
(Rodrigo Ferreira)
November 11, 2010, 4:27pm
1
Hi,
I am wondering what would be the best way to take a yii website off the air for maintenance.
Anyone has experience with that?
I would like to have a simple page showing “we’re off the air, please, come back later”,
closing db connections, but ideally waiting for users that were browsing the site before the
maintenance page kicked in to finish their navigation as they might be in the middle of something.
Is there a right way of doing it?
Thanks in advance for any help!
Best
thinkt4nk
(Thinkt4nk)
November 11, 2010, 5:21pm
2
I would probably just replace /index.php to display what you want. You could create another virtual host to point to a different bootstrap file while you work on the application.
~thinkt4nk
jacmoe
(Jacob Moen)
November 11, 2010, 5:27pm
3
thinkt4nk
(Thinkt4nk)
November 11, 2010, 5:40pm
4
That’s cool! I didn’t even know about ‘catchAllRequest’.
~thinkt4nk
raugfer
(Rodrigo Ferreira)
November 11, 2010, 6:58pm
5
I will probably use a solution that mixes both suggestions.
I’ll do the check for ‘.maintenance’ file in ‘index.php’:
<?php
require_once(dirname(__FILE__).'/../yii/framework/yii.php');
$config=file_exists(dirname(__FILE__).'/.maintenance')
? include(dirname(__FILE__).'/protected/config/maintenance.php')
: include(dirname(__FILE__).'/protected/config/main.php');
Yii::createWebApplication($config)->run();
And then ‘maintenance.php’ boils to:
<?php
return array(
'catchAllRequest'=>array('site/maintenance'),
);
That way I can avoid any interaction with other components,
specially the database (I am using CDbHttpSession in ‘main.php’).
Thanks for the helpful comments!
GSTAR
(Omzy83)
November 12, 2010, 3:08pm
6
What if I want to provide my client with the facility to put the site in online/offline mode from a backend setting?
jacmoe
(Jacob Moen)
November 12, 2010, 3:12pm
7
Use PHP to create a .maintenance file - and likewise remove it.
For the best of both worlds: combine the extension with the tip.
The extension allows admins to login.