patrol icon indicating copy to clipboard operation
patrol copied to clipboard

Feature Idea: Maintenance On/Off via craft cli

Open sergeifilippov opened this issue 6 years ago • 6 comments

I use automated deployments that run tasks via cli before deploying an atomic release of a given craft build.

Would be great if you can put the site into maintenance via cli. Like this:

./craft patrol/maintenance-mode/enable
./craft patrol/maintenance-mode/disable

Thank you for making this plugin. 👍🏻

sergeifilippov avatar Oct 27 '18 11:10 sergeifilippov

@sergeifilippov I'm currently working on this and came across a bit of a dilemma. Because Patrol supports turning maintenance mode on/off via the CP (stored in db) or the config file (config/patrol.php), I'm not sure what the best way implement this would be.

File configs take precedence over CP settings.

I suppose enabling/disabling maintenance mode through the command line could update the settings in the db and somehow signal that it should take priority over file configs.

Another option might be to write to the .env file but is not as cross-platform.

Finally, if this change was for deployments only, we could create a simple text file on enable and delete it on disable.

Lot's of ideas, just need to clear my thoughts and figure out what I'm not thinking of. There may be a much simpler solution here.

I'd love your thoughts on this?

selvinortiz avatar Jan 26 '19 15:01 selvinortiz

Hmm to make things even more interesting there is a 3rd possible option.

Get the module to check for an existence of a .maintenance file in the project root. If it exists, site is in maintenance.

Then the cli command is just checking/adding/removing an empty file vs hitting a database on each request.

Just an idea.

sergeifilippov avatar Jan 26 '19 20:01 sergeifilippov

@sergeifilippov I like the idea of the .maintenance file check because I think it could work well as an advanced feature for CI stuff without changing the behavior of config checks significantly.

selvinortiz avatar Apr 21 '19 12:04 selvinortiz

I think @sergeifilippov is spot on when it comes to this feature. That is how the php artisan down / php artisan up commands work in the Laravel framework. I think it just checks for a down file in the storage directory.

adamskyle avatar Sep 09 '19 16:09 adamskyle

@sergeifilippov Bump 👍

sergeifilippov avatar Nov 27 '20 02:11 sergeifilippov

Good thinking with the .maintenance file, as this is especially more of an issue these days modifying plugin settings with project config, and that getting out of sync.

engram-design avatar Jul 26 '22 06:07 engram-design