Open pgasiorowski opened 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).
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
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.
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.
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...
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.
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
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...
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
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.