Move the router to the new signals handler

This commit is contained in:
Alvaro Saurin committed 2015-05-06 15:07:36 +02:00
1 parent dbc4b68301
commit f723d5afd8
2 files changed
+8 -19

No files matched your search

+5
View File
@@ -94,6 +94,11 @@ func (router *Router) Start() {
}
}
func (router *Router) Stop() error {
// TODO: perform greceful shutdown...
return nil
}
func (router *Router) UsingPassword() bool {
return router.Password != nil
}
+3 -19
View File
@@ -7,16 +7,15 @@ import (
"fmt"
"github.com/davecheney/profile"
"github.com/gorilla/mux"
. "github.com/weaveworks/weave/common"
weavenet "github.com/weaveworks/weave/net"
weave "github.com/weaveworks/weave/router"
"log"
"net"
"net/http"
"os"
"os/signal"
"runtime"
"strings"
"syscall"
)
var version = "(unreleased version)"
@@ -126,7 +125,8 @@ func main() {
if httpAddr != "" {
go handleHTTP(router, httpAddr)
}
handleSignals(router)
SignalHandlerLoop(router)
}
func options() map[string]string {
@@ -209,19 +209,3 @@ func handleHTTP(router *weave.Router, httpAddr string) {
log.Fatal("Unable to create http server", err)
}
}
func handleSignals(router *weave.Router) {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGQUIT, syscall.SIGUSR1)
buf := make([]byte, 1<<20)
for {
sig := <-sigs
switch sig {
case syscall.SIGQUIT:
stacklen := runtime.Stack(buf, true)
log.Printf("=== received SIGQUIT ===\n*** goroutine dump...\n%s\n*** end\n", buf[:stacklen])
case syscall.SIGUSR1:
log.Printf("=== received SIGUSR1 ===\n*** status...\n%s\n*** end\n", router.Status())
}
}
}