Adding a SIGTERM Listener to an Effect-Based Server

Hello, for the context of my question see https://github.com/IMax153/advanced-effect-workshop/blob/main/workshop/exercises/session-01/project.ts

I am trying to add a SIGTERM listener to the example.
First, I added a simple Effect.timeout to shutdown the server after 2 seconds and it works as expected
Layer.launch(MainLive).pipe(
  Effect.timeout(2000),
  Effect.tapErrorCause(Effect.logError),
  Effect.runFork
)

Then I tried to replace Effect.timeout with an Effect.async for handle SIGTERM, but it is not executed (added a simple console.log to check)
Therefore I started playing with Effect.log and I try to understand the behaviours of these example, why "Log something here..." has not be written?

Layer.launch(MainLive).pipe(
  Effect.tap(Effect.log("Log something here...")),
  Effect.tapErrorCause(Effect.logError),
  Effect.runFork
)
// but "Log something here..." has not be written
// I see timestamp=2024-06-15T14:46:30.350Z level=INFO fiber=#16 message="Server listening for requests on port: 3000"


Thank you
Was this page helpful?