Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Move the router to the new signals handler
Browse files Browse the repository at this point in the history
  • Loading branch information
inercia committed May 6, 2015
1 parent dbc4b68 commit f723d5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
5 changes: 5 additions & 0 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
22 changes: 3 additions & 19 deletions weaver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -126,7 +125,8 @@ func main() {
if httpAddr != "" {
go handleHTTP(router, httpAddr)
}
handleSignals(router)

SignalHandlerLoop(router)
}

func options() map[string]string {
Expand Down Expand Up @@ -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())
}
}
}

0 comments on commit f723d5a

Please sign in to comment.