Skip to main content
Wildo.ai Coming soon

Service health

Finish active work before stopping

A shared shutdown sequence stops intake, allows active jobs to drain and runs registered cleanup before exit.

The intended shutdown sequence: stop intake, allow active work to drain, attempt signal flushing, then exit.

Finish active work before stopping

A release or scale-down should give work already underway a chance to finish. Wildo coordinates stopping job intake, draining active jobs and running cleanup through one shutdown sequence.

Workers and telemetry participate in the same lifecycle. The drain has a deadline, so the deployment and the application’s job behavior still need to agree on how interrupted work is retried.

Example — Let a worker finish its current deliveries

During a deployment, a worker stops accepting new jobs while its current deliveries complete. Once they finish, registered cleanup can flush telemetry and close connections. If the drain deadline expires, the process proceeds with shutdown and reports the outstanding jobs.

For engineers

Separate stopping intake from releasing resources

WorkerShutdownManagerBackendService exposes two registration points: registerStopHandler runs before draining; onShutdown runs afterward, in reverse registration order. Registering signal handlers is idempotent, and cleanup is protected against double execution across graceful and forced paths.

The following is an illustrative integration inside a custom consumer that already receives the shutdown manager and owns stopConsuming, closeConnections and processJob. These methods represent the application’s existing work; they are not additional Wildo APIs.

shutdownManager.registerStopHandler(() => stopConsuming());
shutdownManager.onShutdown(() => closeConnections());

async function runAcceptedJob() {
  shutdownManager.jobStarted();
  try {
    await processJob();
  } finally {
    shutdownManager.jobCompleted();
  }
}

The finally is essential: failed work must release the counter too. Stop handlers must prevent further admission; cleanup must not close a connection while accepted jobs still need it. Built-in consumers already integrate with the manager; do not count their jobs a second time.

Size the operating window around the work

The manager’s default drain period is 25 seconds. The actual process termination allowance must leave time for stop handlers and cleanup as well as the drain. A long-running job needs interruption and retry semantics appropriate to its side effects; a grace period does not make delivery exactly once.

StageResponsibility
Stop handlersStop accepting additional work
In-flight counterTrack accepted work through success or failure
Drain deadlineBound how long shutdown waits for that work
Shutdown handlersRelease resources and flush registered telemetry
Broker closure and exitFinish the process lifecycle

Telemetry registers its flush with this coordinator rather than owning a competing termination path. A hard kill cannot run that sequence. HTTP requests are not automatically included in the job counter: verify the HTTP host’s own lifecycle and the deployed termination policy separately.

Building a B2B product or an internal tool?

Wildo is not self-service yet. Tell us what you have in mind and we will say plainly whether it fits, and what happens next.