Enhancing Observability for HTTP Server and BullMQ Worker Lifecycle

I'm running an HTTP server alongside a (BullMQ) worker (https://github.com/PREreview/coar-notify/blob/780bb0f13e1d9157388719d57d4a96190f677f4c/src/index.ts#L83). The worker has logging to say when it's started, stopping and stopped, and I'm looking to add similar observability around the server's lifecycle. Outside of Effect, I've used the listening event and Terminus's onSignal and onShutdown options to write log messages. (The BullMQ worker is using non-Effect code, so uses event listeners to log: https://github.com/PREreview/coar-notify/blob/2bf42ad47ab6c217aa826d4bf752e4b03ef93420/src/BullMq.ts#L93-L103))
I've seen that Effect has HttpServer.server.withLogAddress, which handles a message when starting up. Does the following make sense to log a message when started/stopped?
const ServerLive = Router.pipe(
  HttpServer.server.serve(HttpServer.middleware.logger),
  Layer.merge(
    Layer.scopedDiscard(
      Effect.gen(function* (_) {
        const server = yield* _(HttpServer.server.Server)

        yield* _(
          Effect.acquireRelease(Effect.logDebug('HTTP server started'), () => Effect.logDebug('HTTP server stopped')),
          Effect.annotateLogs('address', HttpServer.server.formatAddress(server.address)),
        )
      }),
    ),
  ),
  Layer.provide(NodeHttpServer.server.layer(() => createServer(), { port: 3000 })),
)

Also, how would I write a log message when starting the shutdown process? I'm using NodeRuntime.runMain, which I can see listens for a SIGINT/SIGTERM and interrupts the fiber. What would be a sensible way to add logging to say something like 'Signal received'?
Was this page helpful?