Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ composer.lock
vendor
builds/
tests/vendor/
.rr.yaml
.rr-sample.yaml
psr-worker.php
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ RR_VERSION=1.6.0
# Hardcode some values to the core package
LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${RR_VERSION}"
LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.BuildTime=$(date +%FT%T%z)"
# remove debug info from binary as well as string and symbol tables
LDFLAGS="$LDFLAGS -s"

build(){
echo Packaging $1 Build
Expand Down
24 changes: 24 additions & 0 deletions cmd/rr/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import (
"github.com/spiral/roadrunner/cmd/util"
"github.com/spiral/roadrunner/service"
"github.com/spiral/roadrunner/service/limit"
"log"
"net/http"
"net/http/pprof"
"os"
)

Expand Down Expand Up @@ -116,8 +119,29 @@ func init() {
})
}
}

// if debug --> also run pprof service
if Debug {
go runDebugServer()
}
})
}
func runDebugServer() {
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
srv := http.Server{
Addr: ":6061",
Handler: mux,
}

if err := srv.ListenAndServe(); err != nil {
log.Fatal(err)
}
}

func configureLogger(format string) {
util.Colorize = false
Expand Down
3 changes: 1 addition & 2 deletions cmd/rr/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func stopHandler(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
defer client.Close()

util.Printf("<green>Stopping RoadRunner</reset>: ")

Expand All @@ -48,5 +47,5 @@ func stopHandler(cmd *cobra.Command, args []string) error {
}

util.Printf("<green+hb>done</reset>\n")
return nil
return client.Close()
}
4 changes: 2 additions & 2 deletions service/rpc/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ func Test_Serve_Client(t *testing.T) {
assert.NoError(t, s.Register("test", &testService{}))

go func() { assert.NoError(t, s.Serve()) }()
time.Sleep(time.Millisecond)
time.Sleep(time.Second)

client, err := s.Client()
assert.NotNil(t, client)
assert.NoError(t, err)
defer client.Close()

var resp string
assert.NoError(t, client.Call("test.Echo", "hello world", &resp))
assert.Equal(t, "hello world", resp)
assert.NoError(t, client.Close())
}

func TestSetEnv(t *testing.T) {
Expand Down