The normal process is to put your Drupal site in maintenance mode during deployment process, website shouldn’t be in live mode during config import or update database but this causes service unavailable if you use you are using your Drupal as API or maintenance page if you use Drupal theme, SO
What alternative of maintenance mode to prevent unavailable services in your Drupal project during deployment ?
There is a great module called Read only mode gives you an alternate to the built in Maintenance Mode in Drupal.
The module give you a list of features:
- Put the site in maintenance mode without taking your site offline
- Easy to configure whitelist of forms that should remain available
- Easy to configure custom warning messages
- Administrative permissions that override Read Only Mode access restrictions
In our case in the deployment process we put our site in maintenance mode before post deploy job (import config + update database) and put back the site after this job finish, as result the API returning 500 response in this period.
To solve this problem instead of putting the site on maintenance mode just make it read only using:
# Put the site on readonly mode. drush cset readonlymode.settings enabled 1 \ --verbose \ -y
and then after post deploy job done put your site up via:
# Put back the site live. drush cset readonlymode.settings enabled 0 \ --verbose \ -y
now your API serve your frontend / your front site is accessible even during deployment!