[Haskell-cafe] Web servers: Running them multiple times in a ghci session

Jeremy Shaw jeremy at n-heptane.com
Fri Apr 12 04:28:41 CEST 2013

The problem is that ^C only kills the main thread, but does not kill
any child threads that have been spawned.

In happstack the Conf has an optional field where you can supply a
ThreadGroup. When threads are forked they will be registered with the
ThreadGroup, and when you ^C, all those threads can be killed. That
obviously has overhead, so by default we do not use it. But for
development in GHCi it can be a huge time saver.


Perhaps you can do something similar..

- jeremy

On Thu, Apr 11, 2013 at 12:03 AM, Niklas Hambüchen <mail at nh2.me> wrote:
> I'm writing a web server app, which I run in ghci:
> :main localhost 8000
> Unfortunately, after Ctrl-C and :reload, running it again:
> ** Exception: bind: resource busy (Address already in use)
> This is pretty annoying, because quitting-and-restarting takes a lot of
> time since I have many dependencies.
> How do you deal with this? Can you propose some working code that can be
> wrapped around my main function to make it work?
> My first idea is running main in a separate process.
> If you have a working idea, please also post it as an answer on
> http://stackoverflow.com/questions/15890912/how-do-i-terminate-a-socket-server-in-ghci
> Thanks
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list