Skip to main content

Rolling Reload

Rolling reload restarts processes in batches, allowing zero-downtime updates.

How It Works​

Usage​

CLI​

# Rolling reload with default batch size (1)
runix reload api --rolling

# Reload 3 processes at a time
runix reload api --rolling --batch-size 3

# Wait for readiness between batches
runix reload api --rolling --wait-ready

# Rollback on failure
runix reload api --rolling --rollback

Configuration​

Rolling reload is triggered via CLI flags, not config file. The options are:

OptionFlagDefaultDescription
Batch size--batch-size1Number of processes to reload concurrently
Wait ready--wait-readyfalseWait for health checks between batches
Rollback--rollbackfalseStop and revert on first failure

Implementation​

Located at internal/supervisor/rolling.go:

type RollingReloadOptions struct {
BatchSize int
WaitReady bool
RollbackOnFailure bool
}

Batch Processing​

  1. Processes are sorted by name (deterministic order)
  2. Divided into batches of BatchSize
  3. Each batch is reloaded concurrently using a sync.WaitGroup
  4. Between batches, optionally wait for readiness

Rollback​

When RollbackOnFailure is enabled:

  • If any process in a batch fails to reload, the entire rolling reload is aborted
  • Already-reloaded processes are stopped
  • The error is returned to the caller

Wait Ready​

When WaitReady is enabled:

  • After each batch completes, Runix waits for all reloaded processes to pass health checks
  • If no health check is configured, running state is sufficient
  • Proceeds to the next batch only after all processes in the current batch are ready

Use Cases​

Zero-Downtime API Deployment​

# 3 API instances, reload one at a time
runix reload api --rolling --batch-size 1 --wait-ready

Fast Bulk Reload​

# Reload everything concurrently in batches of 5
runix reload all --rolling --batch-size 5

Safe Database Migration​

# Reload workers, rollback if anything breaks
runix reload worker --rolling --rollback

What's Next​