Expand description
Database-driven maintenance mode for Laravel Rust.
Register the provider in src/app.rs and run laravel migrate:
use laravel::Application;
Application::configure().with_providers(|providers| {
providers.add(laravel_maintenance::MaintenanceServiceProvider);
})Then laravel maintenance:down --secret=let-me-in takes the application down for everyone
except the clients that open /maintenance/let-me-in. The state lives in the database, so
every server sees it. See the README for the commands, the bypass methods and the settings.
Modules§
- events
- Events the package dispatches. Listen to them as to any Laravel Rust event.
- models
- The package’s tables, as Laravel Rust models.
Structs§
- Down
Options - How to turn maintenance mode on, for
enable. - Downtime
- Maintenance mode while it’s on: what the 503 response says.
- Maintenance
Config - The package’s settings, read from the environment. An application changes them in
with_config: - Maintenance
Service Provider - Adds the package’s settings, migrations, 503 view, commands, and the global
check_maintenance_modemiddleware. - Status
- Everything the package stores, for
maintenance:statusand dashboards. - check_
maintenance_ mode - Answers
503 Service Unavailablewhile the application is in maintenance mode, unless the request may pass: its path is inexcept, its IP is on the whitelist, or it carries a valid token in the bypass cookie or header. While the application is down, it also serves the bypass URL,GET /{bypass_prefix}/{token}, which sets the bypass cookie and redirects home.
Enums§
- IpAction
- What
maintenance:ipdoes. - Token
Action - What
maintenance:tokendoes.
Functions§
- add_ip
- Add an IP address to the whitelist, or update its label and expiry.
- add_
token - Add a named bypass token, or replace the value and expiry of the token with that name. Only the token’s SHA-256 hash is stored, so show the value to whoever needs it now: it can’t be read back later.
- disable
- Turn maintenance mode off, and dispatch
MaintenanceModeDisabled. - downtime
- The current maintenance, or
Nonewhen the application is up. Once the end time passes, this turns maintenance mode off and returnsNone. - enable
- Turn maintenance mode on, and dispatch
MaintenanceModeEnabled. - find_
token - The token with this value, if it exists and hasn’t expired. Reads the database without the cache.
- flush_
cache - Forget the cached state and IP whitelist. The functions of this crate that change them call this already; call it after changing the tables some other way.
- hash_
token - The SHA-256 hash of a token, in hex, as the
token_hashcolumn stores it. - is_down
- Whether the application is in maintenance mode. Once the end time passes, this turns
maintenance mode off and returns
false. - is_
ip_ allowed - Whether an IP address is on the whitelist and hasn’t expired.
- is_
token_ allowed - Whether a token exists and hasn’t expired.
- remove_
ip - Remove an IP address from the whitelist. Returns whether it was there.
- revoke_
token - Revoke the bypass token with this name. Returns whether it existed.
- status
- Everything the package stores, read from the database without the cache.