Effect CommunityEC
Effect Community2y ago
9 replies
akatov

akatov's thread

How can I start a long-running service (e.g. a development express server) that can be stopped / restarted through an external event (e.g. on a hot-module reload)?

My approach was to create a ServerLive that uses Effect.acquireRelease to create and start a new express server, and to provide an effect to close it (similar to the https://effect.website/docs/integrations/express example, but without using a Layer.scopedDiscard wrapper).
I've created a scope using const scope = Effect.runSync(Scope.make()); and I'm calling Effect.runFork(Scope.close(scope, Exit.unit)); to destroy it on hot-module-reload.
However, I cannot figure out how to provide the scope to ServerLive and how to start it.
Was this page helpful?