1

In Step 6 of the Project Config Environment Setup, it is suggested to disable allowAdminChanges so that changes aren't lost unexpectedly on production environments. I maintain a Craft CMS site which occasionally needs to temporarily enter maintenance mode during upgrades to the CraftCMS and/or other integrated systems with the CraftCMS. Our team uses Craft's isSystemLive configuration to enable/disable our maintenance mode pages.

Since isSystemLive is a setting hidden in the Control Panel when allowAdminChanges is set to true, how may I temporarily change isSystemLive during system upgrades?

1 Answer 1

2

You can use the console commands off and on to take the system offline or online, respectively. This bypasses the allowAdminChanges setting and is explicitly intended for usage during deployments.

In fact, our deployment script for Craft projects uses this to take the system offline while the deployment is taking place:

# create db backup before deployment
php craft db/backup

# turn on maintenance mode
php craft off --retry=15

# pull, migrate, apply project config, etc

# turn off maintenance mode
php craft on

Update: System status with environment variables

Since Craft 3.7.22 you can use environment variables to manage the system status. See the release notes for details. If you're using a hosting solution that allows you to change the environment in your deployment script (either through an API or by writing to the .env file directly), you can use that to take the system offline. This way, applying the project config won't change the system status.

Further improvements for this are planned for Craft 4, according to Brandon:

So I am thinking for Craft 4 we will:

  • Deprecate isSystemLive
  • Repurpose Maintenance Mode to be the new primary way of determining whether the system is live, rather than having anything to do with updating (we are going to be dropping the ability to update within the control panel when Dev Mode isn’t enabled anyway, so conflicts aren’t a concern anymore)
  • Drop system.live from the project config

See this issue on Github for details.

4
  • How do you avoid changing your system status during the craft project-config/apply step? Committed in our repository is something like: ``` system: live: true ``` so when we apply our project config changes, CraftCMS goes back online (even when we want to do further work after applying the project config). Sep 20, 2021 at 14:22
  • @JosephKerkhof Yeah that's tricky, haven't found a solution to that either. Maybe just turn the system off again after applying the config and before performing any final steps? Even with a large site, applying the config shouldn't take too long, so the time window for users to see a potentially broken site is really small. Maybe post this as an issue to Github, I think the off command should supersede the project config in this scenario.
    – MoritzLost
    Sep 20, 2021 at 14:28
  • 1
    I agree with your opinion that off should supersede this in project config. I'll make an issue on GitHub and post it back here. Sep 20, 2021 at 14:30
  • 1
    I have created a GitHub issue to capture this conversation: github.com/craftcms/cms/issues/9855 Sep 20, 2021 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.