[TASK] improve cleanup
This commit is contained in:
parent
971744c5d2
commit
5f305761b1
|
@ -4,6 +4,9 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
goji "goji.io"
|
goji "goji.io"
|
||||||
|
|
||||||
|
@ -34,5 +37,19 @@ func main() {
|
||||||
// Startwebsrver
|
// Startwebsrver
|
||||||
router := goji.NewMux()
|
router := goji.NewMux()
|
||||||
http_api.BindAPI(router)
|
http_api.BindAPI(router)
|
||||||
http.ListenAndServe(config.WebserverBind, router)
|
srv := &http.Server{
|
||||||
|
Addr: config.WebserverBind,
|
||||||
|
Handler: router,
|
||||||
|
}
|
||||||
|
go srv.ListenAndServe()
|
||||||
|
|
||||||
|
// Wait for system signal
|
||||||
|
sigs := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
sig := <-sigs
|
||||||
|
|
||||||
|
// Stop services
|
||||||
|
srv.Close()
|
||||||
|
|
||||||
|
log.Println("received", sig)
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue