PhalconEye / phalconeye

PhalconEye CMS Powered by Phalcon Framework
Other
413 stars 97 forks source link

[NFR] Read-only mode for maintenance #70

Open pgasiorowski opened 10 years ago

pgasiorowski commented 10 years ago

A simple switch somewhere in system config for read-only mode will be nice to have at some point.

This would be useful for times where some database maintenance is needed such as:

I'm not sure if it'd be possible to control each module globally with this option or if each module will have to implement this on its own.

lantian commented 10 years ago

:+1:

It is very simple... It can depends on config option maintenance key, if this key is present Application.php will redirect to /public/maintenance.html (mb not redirect, mb just print file_get_contents())... BTW maintenance key can be a key, that can be entered at maintenance to access to working site (via current session).

pgasiorowski commented 10 years ago

That would be possible even with simple .htaccess or nginx redirect. What I actually had in mind is to provide restricted (but still) access to entire site.

Just like stackoverflow does during maintenance to handle high-availability

lantian commented 10 years ago

Yep, and why u can't restrict it via this maintenance key ?

That would be possible even with simple .htaccess or nginx redirect.

But it must be accesible from admin panel.

pgasiorowski commented 10 years ago

A few possible situations would be:

Basically everything which require database write. This enables you to send all reads to replicas while new master is being updated/prepared.

lantian commented 10 years ago

Oh... u mean read-only access... didn't notice it in title of this issue... hm... I really can't understand that mode )))... it's not usable/possible... let's look on joomla... it cache's full page as php... we have no such feature... and wouldn't coz it is bad... Read-only access possible only that way... Maintenance... what is this? This is work stop... process stop... in our case for update/upgrade... and when update is in progress - read or write - is doesn't metter - in that time database structure can be broken - so... read is not possible... that's why it is contradictory...

pgasiorowski commented 10 years ago

that's why it is contradictory

I would image that such upgrade takes place on a separate master and a set of replicas (new environment) while read-only replicas serve read-only content (old environment) thus allowing for smooth upgrade. Once maintenance is completed you turn off the read-only mode and switch to the new environment. This can only be achieved if read-only mode is accounted in application. Users still can login, access restricted areas of the page but they can't change anything.

pgasiorowski commented 10 years ago

There is a wordpress plugin which tries to do this: http://www.wpbeginner.com/plugins/how-to-put-your-wordpress-site-in-read-only-state-for-site-migrations-and-maintenance/

And generally this has been discussed on SilverStripe's group: https://groups.google.com/forum/#!topic/silverstripe-dev/GD_vcU1SaRI

lantian commented 10 years ago

Yes... but this is for blog... in that context - it is easy.. but not in unfinished complex system, when final system will be never understanded for us.

I can set this as "low"... but this feature may lead to different problems.. like when we will have extension store.. we will need to add label to modules, that will identity module as "read-only mode is supported" - that means, that market will have estimativly 50% / 50% supported modules and unsupported... it will be not very nice..

As for implementation - it seems to me quit simple - creating own db adapter, that will have "read-only" flag, when flag is enabled - all operations with INSERT/UPDATE will thrown a special exception type... and it will be special method that will check that flag for submodules... like if $db->isReadOnly()){ ... todo ... } .... if there will be no flag in controller (e.g. in blog creation form) - an exception will be thrown... while exception will have special type (if it unhandled) - a special error page will be shown, like... this part of system is currently under update.... something like that...

pgasiorowski commented 10 years ago

If it was possible with a plugin that's even better. Please keep this open for now, I'll try experimenting with db adapter and/or plugin when I have a few spare minutes