diff options
author | Wolfy-J <[email protected]> | 2018-06-15 15:54:14 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-15 15:54:14 +0300 |
commit | dfef39c64132192d13e2315364a74f1b0244791e (patch) | |
tree | b0959bbbb1ca5a16d94646454d7f2e9340081915 /cmd/rr | |
parent | ccd297dbe2586b3fd29854f72f795be9e818522e (diff) |
readme, samples, golint, build scripts
Diffstat (limited to 'cmd/rr')
-rw-r--r-- | cmd/rr/.rr.yaml | 2 | ||||
-rw-r--r-- | cmd/rr/cmd/root.go | 6 | ||||
-rw-r--r-- | cmd/rr/cmd/version.go | 6 | ||||
-rw-r--r-- | cmd/rr/debug/debugger.go (renamed from cmd/rr/debug/listener.go) | 28 | ||||
-rw-r--r-- | cmd/rr/main.go | 2 |
5 files changed, 24 insertions, 20 deletions
diff --git a/cmd/rr/.rr.yaml b/cmd/rr/.rr.yaml index ab0f3e7f..775cd6c3 100644 --- a/cmd/rr/.rr.yaml +++ b/cmd/rr/.rr.yaml @@ -47,7 +47,7 @@ http: # static file serving. static: # serve http static files - enable: false + enable: true # root directory for static file (http would not serve .php and .htaccess files). dir: "public" diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go index b1f3ea9a..1a21cfc9 100644 --- a/cmd/rr/cmd/root.go +++ b/cmd/rr/cmd/root.go @@ -45,7 +45,11 @@ var ( Use: "rr", SilenceErrors: true, SilenceUsage: true, - Short: utils.Sprintf("<green>RoadRunner, PHP Application Server.</reset>"), + Short: utils.Sprintf( + "<green>RoadRunner, PHP Application Server:</reset>\nVersion: <yellow+hb>%s</reset>, %s", + Version, + BuildTime, + ), } ) diff --git a/cmd/rr/cmd/version.go b/cmd/rr/cmd/version.go new file mode 100644 index 00000000..5edb7543 --- /dev/null +++ b/cmd/rr/cmd/version.go @@ -0,0 +1,6 @@ +package cmd + +var ( + Version = "1.0.0" // Placeholder for the version + BuildTime = "development" // Placeholder for the build time +) diff --git a/cmd/rr/debug/listener.go b/cmd/rr/debug/debugger.go index f137b06f..0621285b 100644 --- a/cmd/rr/debug/listener.go +++ b/cmd/rr/debug/debugger.go @@ -7,32 +7,32 @@ import ( "github.com/spiral/roadrunner/service/http" ) -// Listener provide debug callback for system events. With colors! -type listener struct{ logger *logrus.Logger } - -// NewListener creates new debug listener. -func NewListener(logger *logrus.Logger) *listener { - return &listener{logger} +// Listener creates new debug listener. +func Listener(logger *logrus.Logger) func(event int, ctx interface{}) { + return (&debugger{logger}).listener } -// Listener listens to http events and generates nice looking output. -func (s *listener) Listener(event int, ctx interface{}) { +// listener provide debug callback for system events. With colors! +type debugger struct{ logger *logrus.Logger } + +// listener listens to http events and generates nice looking output. +func (s *debugger) listener(event int, ctx interface{}) { // http events switch event { case http.EventResponse: log := ctx.(*http.Event) - s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.Uri)) + s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.URI)) case http.EventError: log := ctx.(*http.Event) if _, ok := log.Error.(roadrunner.JobError); ok { - s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.Uri)) + s.logger.Info(utils.Sprintf("%s <white+hb>%s</reset> %s", statusColor(log.Status), log.Method, log.URI)) } else { s.logger.Info(utils.Sprintf( "%s <white+hb>%s</reset> %s <red>%s</reset>", statusColor(log.Status), log.Method, - log.Uri, + log.URI, log.Error, )) } @@ -70,12 +70,6 @@ func (s *listener) Listener(event int, ctx interface{}) { } } -// Serve serves. -func (s *listener) Serve() error { return nil } - -// Stop stops the Listener. -func (s *listener) Stop() {} - func statusColor(status int) string { if status < 300 { return utils.Sprintf("<green>%v</reset>", status) diff --git a/cmd/rr/main.go b/cmd/rr/main.go index 40f191c6..4ab2fbe2 100644 --- a/cmd/rr/main.go +++ b/cmd/rr/main.go @@ -55,7 +55,7 @@ func main() { cobra.OnInitialize(func() { if debugMode { service, _ := rr.Container.Get(http.ID) - service.(*http.Service).AddListener(debug.NewListener(rr.Logger).Listener) + service.(*http.Service).AddListener(debug.Listener(rr.Logger)) } }) |