diff options
author | Wolfy-J <[email protected]> | 2018-05-29 20:31:27 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-05-29 20:31:27 +0300 |
commit | 130da89a94f044fafed584ad5430b59991f317c7 (patch) | |
tree | b6fac7a256b6089eb04ff6bacfbd138ada9382bc /cmd | |
parent | e45daa3bbfd5e95889d00ba3cf9ff6c95101bcb2 (diff) |
updates for the server support
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/rr-php/cmd/serve.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/cmd/rr-php/cmd/serve.go b/cmd/rr-php/cmd/serve.go index cac830ac..dc15b6df 100644 --- a/cmd/rr-php/cmd/serve.go +++ b/cmd/rr-php/cmd/serve.go @@ -18,9 +18,10 @@ import ( "github.com/spf13/cobra" "github.com/spiral/roadrunner" "os/exec" - "log" "time" "github.com/sirupsen/logrus" + "github.com/spiral/roadrunner/server" + "net/http" ) func init() { @@ -31,20 +32,20 @@ func init() { } func serveHandler(cmd *cobra.Command, args []string) { - r := roadrunner.NewRouter( + rr := roadrunner.NewRouter( func() *exec.Cmd { return exec.Command("php", "/Users/wolfy-j/Projects/phpapp/webroot/index.php", "rr", "pipes") }, roadrunner.NewPipeFactory(), ) - err := r.Configure(roadrunner.Config{ + err := rr.Configure(roadrunner.Config{ NumWorkers: 1, AllocateTimeout: time.Minute, DestroyTimeout: time.Minute, }) - r.Observe(func(event int, ctx interface{}) { + rr.Observe(func(event int, ctx interface{}) { logrus.Info(ctx) }) @@ -52,10 +53,13 @@ func serveHandler(cmd *cobra.Command, args []string) { panic(err) } - for i := 0; i < 10; i++ { - r.Exec(&roadrunner.Payload{}) - } - - log.Print(r.Workers()) + logrus.Info("serving") + http.ListenAndServe(":8080", server.NewHTTP( + server.HTTPConfig{ + ServeStatic: true, + Root: "/Users/wolfy-j/Projects/phpapp/webroot", + }, + rr, + )) } |