Helios

Graceful shutdown

Pause with stop(), then tear down with close().

Source: examples/graceful-shutdown.ts

stop() pauses the scheduler while keeping targets. close() is final teardown (also what Node process handlers call). Both hooks are optional.

import { createSacnSource } from "@helioslx/core";
import { RecordingTransport } from "@helioslx/core/testing";

const source = createSacnSource({
  transport: new RecordingTransport(),
  ownsTransport: true,
  onStop: () => {
    console.info("Scheduler paused.");
  },
  onClose: () => {
    console.info("Source closed.");
  },
});

await source.universe(1).setChannels({ 1: 255 });

await source.stop();
await source.close();

Related: Lifecycle.