Add "Maintenance Mode" option for Website

11 views
Skip to first unread message

Dmitry A.

unread,
Dec 19, 2011, 12:29:22 AM12/19/11
to in-por...@googlegroups.com
Hi Alex, Phil


For quite some time we have talked (especially with Alex) about having Website Maintenance Mode.

At some point we have already created the task for this in In-Portal 5.2.0, but looks like there is NO discussion yet + some of the ideas needs to be finalized here before implementing.

Please review my description of the task and let me know if any notes/issue. ANY feedback is welcome:



I. Enabling "Maintenance Mode"
==============================
Add 2 new options to "debug.php" file at the top

MAINTENANCE_MODE - 1 - similar to DBG ON/OFF settings
MAINTENANCE_MODE_IPS - will list IPs or hosts the same way DBG works separating with semi-colon


II. Managing "Maintenance Mode Messages"
==============================
1. NEW "Maintenance Mode" section under Admin->Configuration->Advanced. 

Will have options:

a. Front-End message (textarea, from from here to be put in to Template and shown when Maintenance mode is ON or there is NO DBG connection)
b. Admin message  (textarea, from from here to be put in to Template and shown when Maintenance mode is ON or there is NO DBG connection Admin Login screen).


III. Front End behavior:
=============
1. END all Existing Sessions and LOGOUT users.

2. AUTO-REDIRECT all New and Existing Users to special Page (generated from the Template) stating that site is in "Maintenance Mode" and displays System Message (defined via Site Configuration in Admin)

3. EXCEPTIONS are IPs specified in Admin Config settings (see above)

4. ALWAYS auto-redirect to this generated Front-end page if there is NO DB Connection (for some reason) even if my IP is in list of MAINTENANCE_MODE_IPS.


IV. Admin behavior:
==========
1. END all Existing Sessions and LOGOUT users.

2. AUTO-REDIRECT to special Admin Page (generated from the Template) stating that site is in "Maintenance Mode" and displays System Message (defined via Site Configuration in Admin)

3. EXCEPTIONS are IPs specified in Admin Config settings (see above)

4. ALWAYS auto-redirect to this generated Admin page if there is NO DB Connection (for some reason) even if my IP is in list of MAINTENANCE_MODE_IPS.



Here is the original task (OLD description there yet): 

65: Add "Maintenance Mode" option for website - http://tracker.in-portal.org/view.php?id=65




DA

Phil -- wbtc.fr --

unread,
Dec 19, 2011, 3:59:26 AM12/19/11
to in-por...@googlegroups.com
Hi Dmitry,

this is a good point to restart this thread.

I'd suggest here in part II another option: c. ability to choose a template user will be redirected too.

Why this? Because website owner would likely keep people in touch, for example by showing a subscribe to newsletter form, or any other type of content.
Then all would act as you proposed, but users would see a special template, and of course no other template could be seen using /template syntax, thanks to IP setup in debug mode.

Is it needed that MAINTENANCE_MODE_IPS are different from DEBUG_IP ones?

p



2011/12/19 Dmitry A. <dand...@gmail.com>

Alexander Obuhovich

unread,
Dec 19, 2011, 4:56:24 AM12/19/11
to in-por...@googlegroups.com
There is a typo error in "there is NO DBG connection", that should say " there is NO DB connection".


I'd suggest here in part II another option: c. ability to choose a template user will be redirected too.

In maintenance mode you can break down whole In-Portal installation, but users must see valid page when they visit website. That's why we define a page, that can be displayed even without DB connection to inform users about maintenance. We can't use regular TPL file with all <inp2: tags in it.

We can have /themes/theme_name/maintenance.tpl file, but we will only use it once to generate standalone /system/maintenance.php page to show to front-end users. This page would include text that is entered in Front-end message  setting in maintenance mode settings.


Goal of maintenance mode is to lower load on the website and safely perform upgrade of db for example. Maybe making website inaccessible isn't a good idea for websites with tons of visitors, but I haven't seen much In-Portal based websites with such a big loads and a need for an upgrade using maintenance mode.

Phil -- wbtc.fr --

unread,
Dec 19, 2011, 9:45:18 AM12/19/11
to in-por...@googlegroups.com
I got it, it's a good feature to have this maintenance mode.

For a website without such big loads, it could be created a template for maintenance, like the one I've suggested.


2011/12/19 Alexander Obuhovich <aik....@gmail.com>

Alexander Obuhovich

unread,
Dec 19, 2011, 9:48:47 AM12/19/11
to in-por...@googlegroups.com
Then your template should not allow any dynamic actions, like subscription, since it can't be processed while maintenance mode is enabled.

Phil -- wbtc.fr --

unread,
Dec 19, 2011, 9:52:13 AM12/19/11
to in-por...@googlegroups.com
not exactly that: my special template is a way for admin to put website on "light" maintenance mode, and I just left this idea in groups for info, but it's not relevant in our discussion about a real maintenance mode, as you've explained just before.


2011/12/19 Alexander Obuhovich <aik....@gmail.com>

Dmitry A.

unread,
Dec 19, 2011, 8:22:06 PM12/19/11
to in-por...@googlegroups.com
Hi guys,


After further brainstorming this topic here is what crossed our minds.


I'll try to outline the entire process flow below:

Front-end
1. Soft Maintenance setting is ON - I get redirected (unless my IP specified) with 301 code to some specific Template/page no matter where I go (ie. system/maintenance.html). If necessary we can still process the Events since have connection to DB active, but as soon as I try going to another template I'll get required back

2. Hard Maintenance setting is ON - I get redirected (unless my IP specified) with 301 code to some specific Template/page no matter where I go (ie. system/maintenance.html).

Admin
1. Soft Maintenance setting is ON - I get redirected (unless my IP specified) with 301 code to some specific regular Admin page, but can see Message instead of Login Form. No users can login in Admin (need to check that on Event level) except for those who added as exemptions by IP/host.

2. Hard Maintenance setting is ON - I get redirected (unless my IP specified) with 301 code to some specific Template/page no matter where I go (ie. system/maintenance.html).

NO DB connection

Always redirect to Hard Maintenance template/page when there is NO DB connection/failed.


Here is how I propose managing this:

Both Soft Maintenance & Hard Maintenance - initiated from debug.php file by settings. 

NOTE that we'd like to control if this applies ONLY to Front-end or/and to Admin. Below is an example for new debug.php options:

define('MAINTENANCE_MODE', 0); // Front-end, set to 1 for SOFT Maintenance mode, set to 2 for HARD Maintenance mode (no DB connection)
define('MAINTENANCE_MODE_ADMIN', 0); // Admin, set to 1 for SOFT Maintenance mode, set to 2 for HARD Maintenance mode (no DB connection)
define('MAINTENANCE_MODE_IPS', ''); // Define IP addreses/hosts, which will be able to contrinue accessing Website (Front-end and/or Admin)


II. Template management

On the Theme level (add/edit theme in Admin) there will be a way to specify which template you want to use for Soft or Hard Maintenance modes with option to GENERATE Static HTML file under "system/maintenance.php". This means that you can have 1 single maintenance template for both cases or 2 separate ones.

Additionally, we'll have to add 2 new entries to theme.xml under Theme installation folder (so all themes get it by default)

<soft_maintenace_template>maintenance</soft_maintenace_template>
<hard_maintenace_template>maintenance</hard_maintenace_template>

In result, we'll need 2 more fields for Themes table (SoftMaintenanceTemplate and HardMaintenanceTemplate) + 2 Input fields on Add/Edit Theme form + 1 Generate button which will be always SHOWN even if it's not a Primary theme. I see NO reason to disallow Generating Static HTML file from ANY theme if they fill like it!

Question: that Soft Maintenance template will be ALWAYS loaded from Primary theme if that template exists. If case if it does NOT exists we'll load our 404 Template by default (or No redirect by detault)?


I am still proposing to keep 2 new Textarea fields under Configuration->Advanced->Maintenance Mode sub-section. One for Front-end and another for Admin. This is just going to be easy to manage from there (specifically for Soft Maintenance modes), but Webmasters are NOT limited to changes they can do in the templates.


What do you think?


DA

Alexander Obuhovich

unread,
Dec 20, 2011, 3:50:57 AM12/20/11
to in-por...@googlegroups.com
Why we need separate MAINTENANCE_MODE_ADMIN constant. The Admins are the users, who do maintenance and when you do it why there is a need to allow other admins to be logged-in?
Also I don't seem to understand a need for 2 different templates for soft/hard maintenance since users will be redirected back to them if they try anything. And I guess users will see the same message about maintenance. 

You had copy/paste errors there Dmitry (in template name) and you missed main idea:


Each theme can have maintenance.tpl file (default name) or any other TPL that is specified in "/_install/theme.xml" file. Pressing Generate button in theme would statically compile that TPL into pure HTML, that will be used in cases, when DB isn't accessible (hard mode). Statically compiled file will be located in "/system/maintenance.php" and it will be file from the theme where you pressed "Generate" button last.

Phil -- wbtc.fr --

unread,
Dec 20, 2011, 6:46:57 AM12/20/11
to in-por...@googlegroups.com
Dmitry, I didn't had such great idea of mixing previous ones, but I think it's awesome (while maybe not used by many users actually ^^). IDea to lock admin login is also good, by preventing any unwanted changes.

Alex, the difference between soft and hard maintenance are as follow:
on soft maintenance, you prepare/test some new things in real conditions, or just want to put website on hold for few hours/day. You can still interact with users (newsletter subscription, or execute any inp2 tags).

In hard maintenance mode, you perform big changes and lock DB.

Until now, I'm using a separate template as soft maintenance, and set it as primary when needed. Your soft mode adds a better level of security, by preventing anybody to access another template by typing it's name.

Alex, what do you think of these usages?

Dmitry, this idea seems really inspired from real case, did you had any projects where it could have been needed?



2011/12/20 Alexander Obuhovich <aik....@gmail.com>

Alexander Obuhovich

unread,
Dec 20, 2011, 8:11:56 AM12/20/11
to in-por...@googlegroups.com
But what difference between soft/hard mode to end user who's IP isn't listed in MAINTENANCE_IPS list? No difference I guess, since he is redirected to maintenance template in any case.

Dmitry A.

unread,
Dec 23, 2011, 5:13:56 PM12/23/11
to in-por...@googlegroups.com
Hi everyone,


Some further ideas that I have ran by Alex and we have agreed on:


1. Following variables will be added to top portion of DEBUG.PHP (after DBG_MAX_SQL_TIME):

define('MAINTENANCE_MODE_FRONT', 0); // Set to 1 for SOFT Maintenance mode, set to 2 for HARD Maintenance mode (no DB load)
define('MAINTENANCE_MODE_ADMIN', 0); // Set to 1 for SOFT Maintenance mode, set to 2 for HARD Maintenance mode (no DB load)
define('MAINTENANCE_MODE_IPS', ''); // Define IP addresses/hosts, which will be able to continue accessing website

There will be 2 separate settings - 1 for Front and 1 for Admin with single List of IPs to exclude from Maintenance. User can specify if he wants SOFT or HARD Maintenance mode enabled.

Soft Front - all users (except excluded IPs/hosts) are logged out and auto-redirected (301 code) to the specified Front-end template (setting below)

Soft Admin - all users (except excluded IPs/hosts) are logged out and auto-redirected (301 code) to the Admin Login page which will display the message (setting below) instead of the usual Login Form.

Hard Front / Admin - all users (except excluded IPs/hosts) are logged out and auto-redirected (301 code) to Static page that was generateed from template (setting below) - http://www.yourwebsite.com/system/maintenance.php

NOTES:

a. in case if there is NO DB Connection (Admin, Front, Cron) for ANY reason - user will be automatically redirected to http://www.yourwebsite.com/system/maintenance.php

b. Auto-redirect to 404 page if Soft Maint. template is missing or not specified, but Soft Mode has been enabled.

c. Still try redirecting to http://www.yourwebsite.com/system/maintenance.php even if page is missing.



2. Add 4 new Configuration variables under "Website Settings" (after Perform Exact Search):


MaintenanceMessageFront (Maintenance Message for Front End) - textarea

hint: This message will be shown on Front End when either Soft or Hard Maintenance modes are enabled via debug.php file or there no Database connection.
default: Website is currently undergoing the upgrades. Please come back shortly! <br/><br/>Thank you for your patience.


MaintenanceMessageAdmin (Maintenance Message for Admin) - textarea

hint: This message will be shown on Admin instead of Login form either when Soft or Hard Maintenance modes are enabled via debug.php file or there no Database connection.
default: Website is currently undergoing the upgrades. Please come back shortly! <br/><br/>Thank you for your patience.


SoftMaintenanceTemplate (Template for Soft Maintenance) - input field

hint: This template will be shown to the Front End users when Soft Maintenance mode is active.
default: maintenance


HardMaintenanceTemplate (Template for Hard Maintenance) - input field

hint: This template will be used to static HTML file under /system folder to be shown on Front-end or Admin when Hard Maintenance mode is active. Static page should be generated from specified here template by clicking "Generate" button.
default: maintenance
button: add "Generate Page" button next to the Input field with option to generate/regenerate the template. Don't perform generation if "HardMaintenanceTemplate" is empty or does NOT exists.


3. Add maintenance.tpl Template to Advanced and Default themes 

Using default CMS design and using Front End MaintenanceMessageFront setting. It would be great if we can add nofollow="1" Meta settings for this template in the Head portion of the page



DA

Dmitry A.

unread,
Dec 23, 2011, 5:19:15 PM12/23/11
to in-por...@googlegroups.com
I have updated / added all of the above to the Original task so it should be good to go:

Phil

unread,
Dec 26, 2011, 4:06:26 AM12/26/11
to in-por...@googlegroups.com
I just reply now to your post (I like to take time to read in-extenso all messages), and your note a. about displaying a message if no DB connection is maybe the must of all these. I recently have a problem with mySQL daemon crashed and not rebooted by watchdog, while httpd was running fine. It'd have been really better to display a nice maintenance message ;-)

-- 
Phil
Envoyé avec Sparrow

Reply all
Reply to author
Forward
0 new messages