Skip to main content

Crate laravel_maintenance

Crate laravel_maintenance 

Source
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§

DownOptions
How to turn maintenance mode on, for enable.
Downtime
Maintenance mode while it’s on: what the 503 response says.
MaintenanceConfig
The package’s settings, read from the environment. An application changes them in with_config:
MaintenanceServiceProvider
Adds the package’s settings, migrations, 503 view, commands, and the global check_maintenance_mode middleware.
Status
Everything the package stores, for maintenance:status and dashboards.
check_maintenance_mode
Answers 503 Service Unavailable while the application is in maintenance mode, unless the request may pass: its path is in except, 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:ip does.
TokenAction
What maintenance:token does.

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 None when the application is up. Once the end time passes, this turns maintenance mode off and returns None.
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_hash column 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.