genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

[TASK] improve cleanup

This commit is contained in:
Martin Geno 2017-03-26 19:48:59 +02:00
parent 971744c5d2
commit 5f305761b1
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
1 changed files with 18 additions and 1 deletions

View File

@ -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)
} }