Shutdown sequence
WhenStop(ctx) is called, the system:
- Stops background services (eviction, passivation, scheduler)
- Runs coordinated shutdown hooks (if registered)
- Stops datacenter services (if enabled)
- Snapshots cluster state (if clustered)
- Shuts down user actors depth-first (children before parents)
- Deactivates all grains, each after the messages already in its mailbox
- Shuts down system actors
- Leaves cluster and stops remoting
shutdownTimeout
(default: 5 minutes) bounds the total time.
Shutdown hooks
Register hooks viaWithCoordinatedShutdown(hooks...) when creating the actor system. Hooks run during shutdown, before
actors are stopped.
The ShutdownHook interface
The ShutdownHook interface
- Execute: Run cleanup logic. Use the actor system for final operations.
- Recovery: Return retry and recovery configuration for failures.
Recovery strategies
- ShouldFail: Stop shutdown on hook failure.
- ShouldRetryAndFail: Retry, then stop if still failing.
- ShouldSkip: Skip failed hook, continue.
- ShouldRetryAndSkip: Retry, then skip and continue if still failing.
Configuring recovery
Configuring recovery
Recovery() method.
Shutdown timeout
UseWithShutdownTimeout(duration) when creating the actor system to bound the total shutdown time. The default is 3
minutes.