summaryrefslogtreecommitdiff
path: root/cmd/rr/main.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-11 11:46:40 +0300
committerWolfy-J <[email protected]>2018-06-11 11:46:40 +0300
commit4e54066384b1f2cfb6684c781976d3a9288f1f7e (patch)
treebbda59e6be6bb6bb6e95a865be839becfecf7c19 /cmd/rr/main.go
parentf1e09d869e9a177228aadb6385ad578d2e29f90d (diff)
graceful stop
Diffstat (limited to 'cmd/rr/main.go')
-rw-r--r--cmd/rr/main.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/cmd/rr/main.go b/cmd/rr/main.go
index db696904..07448feb 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)
- "github.com/spiral/roadrunner/service/http"
+ rrhtp "github.com/spiral/roadrunner/service/http"
"github.com/spiral/roadrunner/service/rpc"
"github.com/spiral/roadrunner/service/static"
@@ -35,16 +35,33 @@ import (
"github.com/spiral/roadrunner/cmd/rr/debug"
"github.com/spf13/cobra"
+ _ "net/http/pprof"
+ "os"
+ "log"
+ "runtime/pprof"
+ "net/http"
)
var debugMode bool
func main() {
+ f, err := os.Create("cpu.pprof")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ pprof.StartCPUProfile(f)
+ defer pprof.StopCPUProfile()
+
+ 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(http.Name, &http.Service{})
+ rr.Container.Register(rrhtp.Name, &rrhtp.Service{})
// serving static files
rr.Container.Register(static.Name, &static.Service{})
@@ -55,8 +72,8 @@ func main() {
rr.CLI.PersistentFlags().BoolVarP(&debugMode, "debug", "d", false, "debug mode", )
cobra.OnInitialize(func() {
if debugMode {
- service, _ := rr.Container.Get(http.Name)
- service.(*http.Service).AddListener(debug.NewListener(rr.Logger).Listener)
+ service, _ := rr.Container.Get(rrhtp.Name)
+ service.(*rrhtp.Service).AddListener(debug.NewListener(rr.Logger).Listener)
}
})