diff options
-rw-r--r-- | cmd/rr/http/workers.go | 8 | ||||
-rw-r--r-- | cmd/rr/main.go | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go index 394874fa..d04e37fb 100644 --- a/cmd/rr/http/workers.go +++ b/cmd/rr/http/workers.go @@ -36,6 +36,8 @@ import ( "os" "strconv" "time" + "os/signal" + "syscall" ) var ( @@ -59,6 +61,9 @@ func init() { ) rr.CLI.AddCommand(workersCommand) + + signal.Notify(stopSignal, syscall.SIGTERM) + signal.Notify(stopSignal, syscall.SIGINT) } func workersHandler(cmd *cobra.Command, args []string) (err error) { @@ -87,6 +92,8 @@ func workersHandler(cmd *cobra.Command, args []string) (err error) { tm.Clear() for { select { + case <-stopSignal: + return nil case <-time.NewTicker(time.Millisecond * 500).C: tm.MoveCursor(1, 1) showWorkers(client) @@ -94,7 +101,6 @@ func workersHandler(cmd *cobra.Command, args []string) (err error) { } } - <-stopSignal return nil } diff --git a/cmd/rr/main.go b/cmd/rr/main.go index 470e4795..68311da2 100644 --- a/cmd/rr/main.go +++ b/cmd/rr/main.go @@ -26,7 +26,7 @@ import ( rr "github.com/spiral/roadrunner/cmd/rr/cmd" // services (plugins) - rrhtp "github.com/spiral/roadrunner/service/http" + "github.com/spiral/roadrunner/service/http" "github.com/spiral/roadrunner/service/rpc" "github.com/spiral/roadrunner/service/static" @@ -35,23 +35,17 @@ import ( "github.com/spiral/roadrunner/cmd/rr/debug" "github.com/spf13/cobra" - _ "net/http/pprof" - "log" - "net/http" ) var debugMode bool func main() { - go func() { - log.Println(http.ListenAndServe("localhost:6060", nil)) - }() // provides ability to make local connection to services rr.Container.Register(rpc.Name, &rpc.Service{}) // http serving - rr.Container.Register(rrhtp.Name, &rrhtp.Service{}) + rr.Container.Register(http.Name, &http.Service{}) // serving static files rr.Container.Register(static.Name, &static.Service{}) @@ -62,8 +56,8 @@ func main() { rr.CLI.PersistentFlags().BoolVarP(&debugMode, "debug", "d", false, "debug mode", ) cobra.OnInitialize(func() { if debugMode { - service, _ := rr.Container.Get(rrhtp.Name) - service.(*rrhtp.Service).AddListener(debug.NewListener(rr.Logger).Listener) + service, _ := rr.Container.Get(http.Name) + service.(*http.Service).AddListener(debug.NewListener(rr.Logger).Listener) } }) |