Feature Request: Graceful Reloads and Maintenance Mode

Aperta
#709 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
backend, devops

Direzione di ricerca

Start by reading the existing graceful shutdown lifecycle and the application entry point; the issue does not name their files. Then investigate how the server manages listening sockets, process startup, and maintenance responses. Done means graceful reloads and persistent maintenance mode work as described, including startup failure recovery and draining requests; the scope requires design across several lifecycle and deployment concerns.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Motivation

One of the advantages of traditional Laravel applications is the simplicity of deploying updates to production.

It would be great for Laravel Rust to provide native graceful reloads and maintenance mode, allowing developers to deploy applications on a VPS or bare-metal server without requiring blue/green reverse proxy configs, containers, or external deployment orchestration.

Since Laravel Rust already supports graceful shutdown, these features could build upon the existing application lifecycle.

1. Graceful Reloads

Introduce a command such as:

laravel reload

Alternatively, support sending a SIGUSR2 signal to the running application.

The reload mechanism would:

  • Start a new process using the updated binary.
  • Pass the existing listening sockets to the new process.
  • Wait until the new application has successfully booted.
  • Stop accepting new connections in the old process.
  • Allow the new process to handle all incoming connections.
  • Gracefully drain existing requests and connections in the old process.
  • Terminate the old process once draining is complete.

If the new process fails to initialize, the old process should continue serving traffic without interruption.

2. Maintenance Mode

Introduce commands similar to Laravel PHP:

laravel down
laravel up

Maintenance mode could provide:

  • A customizable maintenance page.
  • HTTP 503 responses for incoming requests (configurable with a parameter so 200 also works)
  • JSON responses for API requests.
  • Configurable Retry-After headers.
  • Secret-based maintenance mode bypass.
  • Persistent maintenance state across process reloads and restarts.
  • Graceful draining of existing application requests.
  • Pausing application-managed queue workers and scheduled tasks where applicable.

Ideally, the down command should optionally wait until all active application requests and relevant background jobs have finished, allowing database migrations to run safely without concurrent application activity.

laravel down --wait

Maintenance responses should be served before executing application middleware or accessing the database.

3. Example Deployment Workflows

Zero-downtime deployment

For deployments that do not introduce breaking changes:

git pull
cargo build --release

# Atomically replace the production binary
mv myapp.new myapp

laravel reload
Deployment requiring maintenance

For deployments involving breaking database migrations or other incompatible changes:

git pull
cargo build --release

laravel down --wait

# Atomically replace the production binary
mv myapp.new myapp

# Run database migrations using the new release

laravel reload
laravel up

Throughout this process, visitors would receive a maintenance page rather than connection errors or application exceptions.

If migrations or the reload fail, the application should remain in maintenance mode until the issue is resolved.

Implementation Considerations

  • Listening socket inheritance to preserve the TCP accept queue.
  • Readiness handshake between old and new processes.
  • Integration with the existing graceful shutdown lifecycle.
  • Persistent maintenance state shared between application processes.
  • Proper handling of WebSockets, SSE, and long-lived connections.
  • Coordination with queue workers and scheduled tasks.
  • Compatibility with process supervisors such as systemd.
  • Prevention of overlapping reload operations.
  • Recovery when a new binary fails to initialize.

Benefits

  • Native zero-downtime deployments.
  • Safe maintenance windows for breaking database migrations.
  • Minimal infrastructure requirements.
  • No dropped in-flight requests during normal deployments.
  • Familiar deployment experience for existing Laravel PHP developers.
  • Consistent application lifecycle management.
  • Simpler self-hosted production environments.
Lingua principale
Rust
Stelle
847
Fork
174
Merge medio
5h 40m
PR unite (30g)
167

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di laravel/rust-framework

Tutte le issue di laravel/rust-framework

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.