Since version 2.16
Maintenance Mode
You may want to put one or more of your stores in maintenance mode while you do some maintenance work/deployment tasks on your store(s).
Front-Commerce comes with an API that allows you to put/remove a store in
maintenance mode. To enable the maintenance mode API you need to set the
FRONT_COMMERCE_MAINTENANCE_MODE_AUTHORIZATION_TOKEN
environment variable.
FRONT_COMMERCE_MAINTENANCE_MODE_AUTHORIZATION_TOKEN=a-secret-token
Once you have setup the FRONT_COMMERCE_MAINTENANCE_MODE_AUTHORIZATION_TOKEN
environment variable the maintenance mode API will be available after restarting
the server
The Maintenance Mode API
Activating the maintenance mode
To activate the maintenance mode on a store which URL is https://example.com/
use the following HTTP request:
curl --location --request POST 'https://example.com/maintenance-mode' \
--header 'Content-Type: application/json' \
--data-raw '{
"token": "a-secret-token"
}'
The token
value must match the secret defined in your application's
FRONT_COMMERCE_MAINTENANCE_MODE_AUTHORIZATION_TOKEN
environment variable.
If your store base URL is https://example.com/en
the URL would be
https://example.com/en/maintenance-mode
.
It is also possible to set a duration (in milliseconds) after which the maintenance mode will be automatically reset:
curl --location --request POST 'https://example.com/maintenance-mode' \
--header 'Content-Type: application/json' \
--data-raw '{
"token": "a-secret-token",
"duration": 3600000
}'
Use this if you have a rough idea of how much time the maintenance task would take or to prevent a user or automated process to forget to deactivate the maintenance mode.
Deactivating the maintenance mode
To deactivate the maintenance mode use the following HTTP request:
curl --location --request DELETE 'https://example.com/maintenance-mode' \
--header 'Content-Type: application/json' \
--data-raw '{
"token": "a-secret-token"
}'
To check the maintenance mode
To check the maintenance mode use the following HTTP request:
curl --location --request GET 'https://example.com/maintenance-mode'
Bypassing the maintenance mode
To bypass the maintenance mode for certain IP addresses you can configure the
FRONT_COMMERCE_MAINTENANCE_MODE_AUTHORIZED_IPS
environment variable. Please
note that you can have multiple IPs separated by a comma like:
FRONT_COMMERCE_MAINTENANCE_MODE_AUTHORIZATION_TOKEN=a-secret-token
FRONT_COMMERCE_MAINTENANCE_MODE_AUTHORIZED_IPS=127.0.0.1,83.65.12.111,2ce8:c427::7156:ad8e
Please configure both v4 and v6 IP as much as possible. You can retrieve your own IP addresses with https://www.whatismyip.com/