using HttpServer
http = HttpHandler() do request::Request, response::Response
show(request)
Response("Hello there")
end
http.events["error"] = (client, error) -> println(error)
http.events["listen"] = (port) -> println("Listening on $port")
server = Server(http)
t = @async run(server, 3000)
This starts a simple little web server asynchronously. The problem is I have no idea how to stop it. I've been going through the Julia documentation and trying to find some function that will remove this task from the queue (kill, interrupt, etc.) but nothing seems to work.
How can I kill this task?
I don't see an official way to end a task specifically, but I think the general solution was the addition of throwto, which allows you to immediately schedule a task with a pending exception.
...
t = @async run(server, 3000)
...
ex = InterruptException()
Base.throwto(t, ex)
close(http.sock) # ideally HttpServer would catch exception to cleanup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With