<p>You can use the <a href="https://craftcms.com/docs/3.x/console-commands.html" rel="nofollow noreferrer">console commands</a> <a href="https://craftcms.com/docs/3.x/console-commands.html#off" rel="nofollow noreferrer">off</a> and <a href="https://craftcms.com/docs/3.x/console-commands.html#on" rel="nofollow noreferrer">on</a> to take the system offline or online, respectively. This bypasses the <code>allowAdminChanges</code> setting and is explicitly intended for usage during deployments.</p>
<p>In fact, our deployment script for Craft projects uses this to take the system offline while the deployment is taking place:</p>
<pre class="lang-bash prettyprint-override"><code># 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
</code></pre>
<h3>Update: System status with environment variables</h3>
<p>Since <a href="https://github.com/craftcms/cms/blob/develop/CHANGELOG.md#3722---2021-11-23" rel="nofollow noreferrer">Craft 3.7.22</a> 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 <code>.env</code> file directly), you can use that to take the system offline. This way, applying the project config won't change the system status.</p>
<p>Further improvements for this are planned for Craft 4, <a href="https://github.com/craftcms/cms/issues/9855#issuecomment-981945745" rel="nofollow noreferrer">according to Brandon</a>:</p>
<blockquote>
<p>So I am thinking for Craft 4 we will:</p>
<ul>
<li>Deprecate <code>isSystemLive</code></li>
<li>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)</li>
<li>Drop <code>system.live</code> from the project config</li>
</ul>
</blockquote>
<p>See <a href="https://github.com/craftcms/cms/issues/9855" rel="nofollow noreferrer">this issue on Github</a> for details.</p>

CC BY-SA 4.0
2021-09-20T14:22:02.377Z
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).
Joseph Kerkhof
CC BY-SA 4.0
2021-09-20T14:28:31.407Z
@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
CC BY-SA 4.0
2021-09-20T14:30:38.963Z
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.
Joseph Kerkhof
CC BY-SA 4.0
2021-09-20T17:40:51.313Z
I have created a GitHub issue to capture this conversation: https://github.com/craftcms/cms/issues/9855
Joseph Kerkhof
CC BY-SA 4.0
2021-09-09T14:00:31.660Z
2021-11-30T09:07:28.700Z
2021-11-30T09:07:28.700Z
MoritzLost
<p>In Step 6 of the <a href="https://craftcms.com/docs/3.x/project-config.html#environment-setup" rel="nofollow noreferrer">Project Config Environment Setup</a>, it is suggested to disable <a href="https://craftcms.com/docs/3.x/config/config-settings.html#allowadminchanges" rel="nofollow noreferrer">allowAdminChanges</a> so that changes aren't <a href="https://craftcms.com/docs/3.x/project-config.html#production-changes-may-be-forgotten" rel="nofollow noreferrer">lost unexpectedly</a> 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 <a href="https://craftcms.com/docs/3.x/config/config-settings.html#issystemlive" rel="nofollow noreferrer">isSystemLive</a> configuration to enable/disable our maintenance mode pages.</p>
<p>Since <code>isSystemLive</code> is a setting hidden in the Control Panel when <code>allowAdminChanges</code> is set to <code>true</code>, how may I temporarily change <code>isSystemLive</code> during system upgrades?</p>

<settings><environmentvariables><projectconfig>
Managing `isSystemLive` with Project Config
# Managing `isSystemLive` with Project Config

(Asked by: username_0 on 2021-09-09)

In Step 6 of the [Project Config Environment Setup](https://craftcms.com/docs/3.x/project-config.html#environment-setup), it is suggested to disable [allowAdminChanges](https://craftcms.com/docs/3.x/config/config-settings.html#allowadminchanges) so that changes aren't [lost unexpectedly](https://craftcms.com/docs/3.x/project-config.html#production-changes-may-be-forgotten) 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](https://craftcms.com/docs/3.x/config/config-settings.html#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?

**Tags:** settings, environmentvariables, projectconfig

---

## 1 answers

### Answer by username_1 on 2021-09-09. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: 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).  
> **username_1**: @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.  
> **username_0**: 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.  
> **username_0**: I have created a GitHub issue to capture this conversation: https://github.com/craftcms/cms/issues/9855  

---

