Framework lifecycle
ServiceGenerated::start / stopC++ userver lifecycle
userver task-based makers, ordered activation, and ownership-safe timeout handling.
When to use
Use this page when implementing maker hooks, owning resources, or diagnosing startup and shutdown.
Behavior
serviceInit,initMakers, andcustomMakersInitprecedeinitRuntime.- Infrastructure and function makers run as named userver async tasks; first failure requests cancellation and is rethrown.
ServiceApp::startstarts execution runtime and activates lifecycle categories in dependency order.- Stop closes non-Sink resources, drains graph execution, then stops Sinks.
C++ userver startup sequence
ConfigurationLoad graph configResolve typed service, stream, connector, and endpoint settings.
FactoriesinitMakersInstall defaults, then run
customMakersInit and serviceStarted.ConstructionInvoke makers onceCreate infrastructure and long-lived functions in parallel.
GraphBuild and bindConstruct streams, callers, endpoint consumers, and transports.
StartOpen admission lastStart dependencies and Sinks before Sources and servers.
C++ userver shutdown sequence
SignalStop requestedCreate one deadline from
shutdownTimeout.AdmissionListeners and SourcesReject new root work and drain accepted calls.
GraphNested workKeep pools, storage, Sinks, and clients alive.
ResourcesPools, storage, SinksRelease graph dependencies in safe order.
TelemetryFlush and releaseMetrics, traces, and logs stop last.
Context::bounded(shutdownTimeout)supplies the shared deadline.- Components stop in reverse dependency order with timeout telemetry.
- Sinks remain alive until graph drain.
- Timed-out graph ownership is preserved to avoid dangling callbacks.
Hooks and boundaries properties
Generated extension points and runtime-owned lifecycle boundaries.
PropertyTypeDescription
initMakersgeneratedAssigns asynchronous maker callables.
customMakersInitvirtual hookOverrides defaults before maker tasks.
initRuntimegeneratedMakes objects, builds graph, and registers lifecycle entries.
serviceStarteduser hookRuns after ServiceApp startup.
stopruntimeIdempotent and called by the destructor.
Lifecycle outline
configure -> make once -> bind -> start -> admit -> drain -> stop