Search by

xddesigners / silverstripe-maintenance-mode

RVXD

Maintenance mode for SilverStripe via a lock file, without locking yourself out. Toggle from the CMS or a deploy script; logged-in CMS users keep browsing.

Package info

github.com/xddesigners/silverstripe-maintenance-mode

Type:silverstripe-vendormodule

pkg:composer/xddesigners/silverstripe-maintenance-mode

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-02 19:32 UTC

This package is auto-updated.

Last update: 2026-12-03 15:28:42 UTC


README

Maintenance mode for Silverstripe without locking yourself out. A lock file toggles a 503 maintenance page for visitors, while logged-in CMS users, the admin/login/dev paths, and allow-listed IPs keep working — so you can deploy, verify, and recover.

The lock file is a plain file (default under assets/, which is usually shared across deploy releases), so maintenance can be toggled from a deploy script before the database is migrated, and from the CMS.

Requirements

  • Silverstripe Framework 6
  • PHP 8.3+

Installation

composer require xddesigners/silverstripe-maintenance-mode

Run dev/build?flush=1 (or sake db:build --flush) once to add the SiteConfig fields.

Toggling maintenance mode

From the CLI / a deploy script (safe before db:build):

sake tasks:maintenance-mode --mode=enable
sake tasks:maintenance-mode --mode=disable
sake tasks:maintenance-mode --mode=status

Or from the CMS: Settings → Maintenance → Enable maintenance mode (with an optional custom message). The checkbox always reflects the real lock-file state, and saving syncs it.

A typical deploy script:

sake tasks:maintenance-mode --mode=enable
# ... pull code, composer install, sake db:build ...
sake tasks:maintenance-mode --mode=disable

Who still gets through

While maintenance mode is on, a request bypasses the maintenance page when any of these hold (everyone else gets a 503):

Bypass Default Config
Request is CLI always —
URL path prefix admin, dev, Security, _resources bypass_paths
Logged-in member with permission CMS_ACCESS or ADMIN bypass_permissions
Request IP (none) allowed_ips

Because admin, Security and _resources are always reachable, a logged-out admin can still log in during maintenance and then browse the front end normally.

Configuration

# app/_config/maintenance-mode.yml
XD\MaintenanceMode\Middleware\MaintenanceMiddleware:
  # Where the lock file lives. Empty = <assets>/.maintenance.lock.
  # Absolute path used as-is; relative resolves against the project base folder.
  lock_file: ''
  bypass_paths:
    - 'admin'
    - 'dev'
    - 'Security'
    - '_resources'
  bypass_permissions:
    - 'CMS_ACCESS'
    - 'ADMIN'
  allowed_ips:
    - '203.0.113.10'
  retry_after: 3600
  # Polls the site and reloads the page the moment it is back (0 disables).
  poll_seconds: 15
  # Colours (banner + icons/dots).
  primary_color: '#13395e'
  accent_color: '#0f9b9b'
  # Page text — OPTIONAL. Leave unset to use the translations (see below); set any of
  # these to override the translation with a fixed string.
  # banner_title: 'Temporarily unavailable'
  # banner_subtitle: 'Thank you for your patience'
  # heading: 'Scheduled maintenance'   # optional line above the message; empty = omitted (config-only, not translated)
  # default_message: 'We are currently making some improvements to the website.'
  # duration_label: 'How long will it take?'
  # duration_text: 'Probably a few minutes...'
  # retry_label: 'Automatic reload'
  # retry_text: 'The site will reload itself when we are done'
  # footer_text: 'For urgent matters, it is best to contact us by phone.'
  # refresh_note: 'This page will automatically refresh when the website is available again.'

default_message is the intro line, and a Maintenance message set in the CMS overrides it (and may contain HTML). During a deploy when the database isn't available yet, the translation / configured default is always used.

Translations

The page text is translatable via standard Silverstripe i18n, shown in the site's current locale. Translations ship for en, nl, de, it, es, fr (lang/<locale>.yml); the page falls back to English for any other locale. Add a locale by dropping another lang/*.yml file in your project, or override individual strings per project with the config keys above (a config value always wins over the translation).

How it works

MaintenanceMiddleware is registered on Director.Middlewares, after the core session and authentication middlewares, so the current member is already resolved when it runs — that is what lets logged-in CMS users keep browsing. When the lock file exists and the request isn't bypassed, it returns a self-contained 503 page (Retry-After, noindex, no-store), so it renders even while themes/manifests are flushing mid-deploy.

The page polls the site every poll_seconds and reloads itself as soon as it is available again, so the maintenance panel disappears on its own when the deploy finishes (a <noscript> meta-refresh covers clients with JavaScript disabled).

Credits

The maintenance-mode concept and status-panel design that inspired this module were demoed by acronica (Gabrijel Gavranović, Terry Duivesteijn et al.). This is an independent reimplementation — original code, with its own copy and theming — built out of appreciation for that idea. Thanks to them for sharing it.

License

BSD-3-Clause.