I am using the Mux library from Gorilla Web Toolkit along with the bundled Go http server.
The problem is that in my application the HTTP server is only one component and it is required to stop and start at my discretion.
When I call http.ListenAndServe(fmt.Sprintf(":%d", service.Port()), service.router)
it blocks and I cannot seem to stop the server from running.
I am aware this has been a problem in the past, is that still the case? Are there any new solutions please? Thanks.
guys how about this
What I've done for such cases where the application is just the server and performing no other function is install an
http.HandleFunc
for a pattern like/shutdown
. Something likeIt does not require 1.8. But if 1.8 is available, then that solution can be embedded here instead of the
os.Exit(0)
call if desirable, I believe.