Reputation: 16059
I'm working on a web server using Scotty. I can run ghci
and keep using :r
to get it to reload my code, but if I even run main
I cant' restart the web server without killing ghci.
How can I cancel main
without closing ghci
? Is there a better way to handle web servers and automatically restart them?
Upvotes: 3
Views: 634
Reputation: 27771
Invoke :set args <arg> ...
in ghci
to set the arguments that will be returned by System.getArgs
.
Then, using the async
package, launch the server in ghci
with something like a <- async main
.
Later invoke cancel a
to kill the server.
See also this link that explains how to reload code even while the server is running.
Upvotes: 5