summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-07-08 22:04:18 -0700
committerGitHub <[email protected]>2018-07-08 22:04:18 -0700
commit47ae9f40b2ead4656bec9ea1204e5c8936cab76c (patch)
tree0d3aad39c0ea1ac697b61047ebf505f69275ba54 /cmd
parentad0562981de801ad32b5bfd48cea9c92793a8cc0 (diff)
parent21bd058003a159ff307565d5b57e3631921a7a96 (diff)
Merge pull request #28 from spiral/feature/arguments
v1.1.0
Diffstat (limited to 'cmd')
-rw-r--r--cmd/rr/.rr.yaml8
-rw-r--r--cmd/rr/cmd/version.go3
-rw-r--r--cmd/rr/debug/debugger.go53
-rw-r--r--cmd/rr/http/reset.go2
-rw-r--r--cmd/rr/http/workers.go2
5 files changed, 47 insertions, 21 deletions
diff --git a/cmd/rr/.rr.yaml b/cmd/rr/.rr.yaml
index 775cd6c3..5ea6b345 100644
--- a/cmd/rr/.rr.yaml
+++ b/cmd/rr/.rr.yaml
@@ -38,11 +38,11 @@ http:
# maximum jobs per worker, 0 - unlimited.
maxJobs: 0
- # for how long worker is allowed to be bootstrapped. In nanoseconds :(
- allocateTimeout: 600000000
+ # for how long worker is allowed to be bootstrapped.
+ allocateTimeout: 60
- # amount of time given to worker to gracefully destruct itself. In nanoseconds :(
- destroyTimeout: 600000000
+ # amount of time given to worker to gracefully destruct itself.
+ destroyTimeout: 60
# static file serving.
static:
diff --git a/cmd/rr/cmd/version.go b/cmd/rr/cmd/version.go
index 8cbf7f69..26744922 100644
--- a/cmd/rr/cmd/version.go
+++ b/cmd/rr/cmd/version.go
@@ -4,7 +4,8 @@ import "time"
var (
// Version - defines build version.
- Version = "development"
+ Version = "local"
+
// BuildTime - defined build time.
BuildTime = time.Now().Format(time.RFC1123)
)
diff --git a/cmd/rr/debug/debugger.go b/cmd/rr/debug/debugger.go
index 0dca43de..ed9a1a56 100644
--- a/cmd/rr/debug/debugger.go
+++ b/cmd/rr/debug/debugger.go
@@ -1,10 +1,12 @@
package debug
import (
+ "fmt"
"github.com/sirupsen/logrus"
"github.com/spiral/roadrunner"
"github.com/spiral/roadrunner/cmd/rr/utils"
- "github.com/spiral/roadrunner/service/http"
+ rrhttp "github.com/spiral/roadrunner/service/http"
+ "net/http"
"strings"
)
@@ -20,21 +22,32 @@ type debugger struct{ logger *logrus.Logger }
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))
- 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))
+ case rrhttp.EventResponse:
+ e := ctx.(*rrhttp.ResponseEvent)
+ s.logger.Info(utils.Sprintf(
+ "<cyan+h>%s</reset> %s <white+hb>%s</reset> %s",
+ e.Request.RemoteAddr,
+ statusColor(e.Response.Status),
+ e.Request.Method,
+ e.Request.URI,
+ ))
+ case rrhttp.EventError:
+ e := ctx.(*rrhttp.ErrorEvent)
+
+ if _, ok := e.Error.(roadrunner.JobError); ok {
+ s.logger.Info(utils.Sprintf(
+ "%s <white+hb>%s</reset> %s",
+ statusColor(500),
+ e.Request.Method,
+ uri(e.Request),
+ ))
} else {
s.logger.Info(utils.Sprintf(
"%s <white+hb>%s</reset> %s <red>%s</reset>",
- statusColor(log.Status),
- log.Method,
- log.URI,
- log.Error,
+ statusColor(500),
+ e.Request.Method,
+ uri(e.Request),
+ e.Error,
))
}
}
@@ -58,7 +71,10 @@ func (s *debugger) listener(event int, ctx interface{}) {
// outputs
switch event {
case roadrunner.EventStderrOutput:
- s.logger.Warning(strings.Trim(string(ctx.([]byte)), "\r\n"))
+ s.logger.Warning(utils.Sprintf(
+ "<yellow>%s</reset>",
+ strings.Trim(string(ctx.([]byte)), "\r\n"),
+ ))
}
// rr server events
@@ -93,3 +109,12 @@ func statusColor(status int) string {
return utils.Sprintf("<red>%v</reset>", status)
}
+
+// uri fetches full uri from request in a form of string (including https scheme if TLS connection is enabled).
+func uri(r *http.Request) string {
+ if r.TLS != nil {
+ return fmt.Sprintf("https://%s%s", r.Host, r.URL.String())
+ }
+
+ return fmt.Sprintf("http://%s%s", r.Host, r.URL.String())
+}
diff --git a/cmd/rr/http/reset.go b/cmd/rr/http/reset.go
index 431b7e88..3bc089ec 100644
--- a/cmd/rr/http/reset.go
+++ b/cmd/rr/http/reset.go
@@ -39,7 +39,7 @@ func init() {
func reloadHandler(cmd *cobra.Command, args []string) error {
svc, st := rr.Container.Get(rpc.ID)
- if st < service.StatusConfigured {
+ if st < service.StatusOK {
return errors.New("RPC service is not configured")
}
diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go
index e697816f..b03c273f 100644
--- a/cmd/rr/http/workers.go
+++ b/cmd/rr/http/workers.go
@@ -74,7 +74,7 @@ func workersHandler(cmd *cobra.Command, args []string) (err error) {
}()
svc, st := rr.Container.Get(rrpc.ID)
- if st < service.StatusConfigured {
+ if st < service.StatusOK {
return errors.New("RPC service is not configured")
}