timbod
timbod

Reputation: 791

Cleanly shutting down a warp server without exiting the process

I am looking at using wai/warp for some custom interprocess communications. This would have the unusual requirement that I would need to start/stop warp instances dynamically within a process. The main issue seems to be cleanly stopping warp. This question is addressed here:

How do I implement a shutdown command in a WAI server?

but the suggested solution end up exiting the process by returning from main. Can I just throw a ThreadKill exception to the warp thread?

This thread:

https://groups.google.com/forum/#!topic/yesodweb/VoenrabRUBQ

suggests that an IORef could be passed on startup, which could trigger a shutdown externally. This sounds ideal, but isn't part of the current API.

Upvotes: 2

Views: 346

Answers (1)

Michael Snoyman
Michael Snoyman

Reputation: 31315

You can run Warp in a separate thread via forkIO and then kill that thread only.

Upvotes: 3

Related Questions