I need to temporarily turn on site maintenance. How to do it?
How to enable site maintenance
Alkir you can set offline
to true
in config.php
.
The key does not exist by default, you could add it under debug for example:
<?php return array (
'debug' => true,
'offline' => true,
'database' =>
array (
// stuff
),
'url' => 'https://yoururl',
'paths' =>
array (
// stuff
),
);
Then set it to false
or remove it to restore access to the forum.
Currently if I'm not mistaken, nobody can access the forum while in offline mode, including admins.
- Edited
clarkwinkelmann Currently if I'm not mistaken, nobody can access the forum while in offline mode, including admins.
PR is in progress: flarum/core1732 ; so yes you are correct.
ok
What would the users see?
I am interested in a read only mode to turn on right before and during upgrades.
MikeJones they see this https://github.com/flarum/core/blob/v0.1.0-beta.8.1/src/Foundation/MaintenanceModeHandler.php#L36, an HTML response with the hard-coded text without any formatting.
I realize it's not even using the translator so no way of changing/translating the message without another extension.
Could be interesting to attempt getting a translation first, then fallback to hardcoded message if the translator is not operational (like it could happen while composer updates files). That way Linguist could be used.
Is this method always the right way to put flarum in maintenance mode ?
brian85 the right way will depend on what you are trying to achieve.
If you are about to run composer commands or move files around, there's a possibility users see errors instead of the offline page of Flarum. In such cases if you want to guarantee users to see your own offline page it might be best to edit your webserver config to serve a different static page while you work on the files.
And if you're looking for read only mode, we don't really have that yet. It could be created as an extension, or by doing some clever caching with a proxy.
clarkwinkelmann And if you're looking for read only mode, we don't really have that yet.
A simple read only mode could be achieved by revoking the create discussion permission to your members and other write permissions and leaving it only to your admins. I assume this is what you mean by "read only" - allow members to only read your forum and not be able to change anything. Correct me if I'm wrong.
Thanks for these explanations.
- Edited
SKevo exactly. It's probably not too complicated to implement, the permission part would work similarly to Suspend and Terms.
But the real question is the purpose. If the intent is to be able to work on or backup the database, then you also need to neutralize online status, login and post read requests, otherwise those will continue to be written to the database.
If the intent is to update composer dependencies, then nothing can really guarantee the website will stay up, as any PHP error or missing file will throw errors. For that you'd need a read-only copy of the forum that's also served as a temporary static website while Flarum files can be moved around behind the scenes.
To pull this off properly would require two different Flarum copies so one can be put in read only mode while the other can be modified. But this probably only makes sense for high traffic websites that need to keep content accessible with minimal downtime.
For most small forums, the base "offline" mode of Flarum is probably enough to make sure nothing gets interacted with until maintenance is complete.
clarkwinkelmann Even the most massive websites go offline for maintenance, I know Office 365 does on occasion (admin portals usually) and when Curse was buying up forums left and right all of the forums they bought had a couple hours downtime during switchovers and upgrades.