verbb / patrol

Easy Maintenance Mode and Smart HTTPS Routing for Craft CMS
MIT License
29 stars 8 forks source link

Feature Idea: Maintenance On/Off via craft cli #14

Open sergeifilippov opened 5 years ago

sergeifilippov commented 5 years ago

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. 👍🏻

selvinortiz commented 5 years ago

@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?

sergeifilippov commented 5 years ago

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.

selvinortiz commented 5 years ago

@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.

adamskyle commented 5 years ago

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.

sergeifilippov commented 3 years ago

@sergeifilippov Bump 👍

engram-design commented 2 years ago

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.