summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-10 20:31:05 +0300
committerWolfy-J <[email protected]>2018-06-10 20:31:05 +0300
commited3a0f2bb25077c7a32a54ddb3754f04ffbdccf3 (patch)
tree9a579e6ce81e7af5e3844fbcf590f9c8db26d90a /cmd
parentade5cc504e2b082d0838cc93c3a185246fdc7834 (diff)
debug mode have been added
Diffstat (limited to 'cmd')
-rw-r--r--cmd/rr/.rr.yaml12
-rw-r--r--cmd/rr/cmd/root.go24
-rw-r--r--cmd/rr/http/reset.go2
-rw-r--r--cmd/rr/http/workers.go14
-rw-r--r--cmd/rr/main.go4
-rw-r--r--cmd/rr/utils/config.go26
-rw-r--r--cmd/rr/utils/cprint.go32
7 files changed, 44 insertions, 70 deletions
diff --git a/cmd/rr/.rr.yaml b/cmd/rr/.rr.yaml
index bf4c699b..9ee75856 100644
--- a/cmd/rr/.rr.yaml
+++ b/cmd/rr/.rr.yaml
@@ -33,7 +33,7 @@ http:
# worker pool configuration.
pool:
# number of workers to be serving.
- numWorkers: 16
+ numWorkers: 1
# maximum jobs per worker, 0 - unlimited.
maxJobs: 0
@@ -53,4 +53,12 @@ static:
dir: "c:/GoProj/phpapp/webroot"
# list of extensions for forbid for serving.
- forbid: [".php", ".htaccess"] \ No newline at end of file
+ forbid: [".php", ".htaccess"]
+
+# rr debugging
+debug:
+ # enable debug output
+ enable: true
+
+ # show individual worker events
+ verbose: true \ No newline at end of file
diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go
index ea7c8a3b..59a43b4e 100644
--- a/cmd/rr/cmd/root.go
+++ b/cmd/rr/cmd/root.go
@@ -24,8 +24,8 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
- "github.com/spiral/roadrunner/cmd/rr/utils"
"github.com/spiral/roadrunner/service"
+ "github.com/spiral/roadrunner/utils"
"os"
)
@@ -49,6 +49,26 @@ var (
}
)
+// ViperWrapper provides interface bridge between v configs and service.Config.
+type ViperWrapper struct {
+ v *viper.Viper
+}
+
+// Get nested config section (sub-map), returns nil if section not found.
+func (w *ViperWrapper) Get(key string) service.Config {
+ sub := w.v.Sub(key)
+ if sub == nil {
+ return nil
+ }
+
+ return &ViperWrapper{sub}
+}
+
+// Unmarshal unmarshal config data into given struct.
+func (w *ViperWrapper) Unmarshal(out interface{}) error {
+ return w.v.Unmarshal(out)
+}
+
// Execute adds all child commands to the CLI command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the CLI.
func Execute() {
@@ -100,5 +120,5 @@ func initConfig(cfgFile string, path []string, name string) service.Config {
return nil
}
- return &utils.ViperWrapper{Viper: cfg}
+ return &ViperWrapper{cfg}
}
diff --git a/cmd/rr/http/reset.go b/cmd/rr/http/reset.go
index 2583f8cd..fd27149d 100644
--- a/cmd/rr/http/reset.go
+++ b/cmd/rr/http/reset.go
@@ -26,7 +26,7 @@ import (
rr "github.com/spiral/roadrunner/cmd/rr/cmd"
"github.com/spiral/roadrunner/rpc"
"github.com/spiral/roadrunner/service"
- "github.com/spiral/roadrunner/cmd/rr/utils"
+ "github.com/spiral/roadrunner/utils"
)
func init() {
diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go
index b5da833d..ddfe337c 100644
--- a/cmd/rr/http/workers.go
+++ b/cmd/rr/http/workers.go
@@ -22,20 +22,20 @@ package http
import (
"errors"
+ tm "github.com/buger/goterm"
+ "github.com/dustin/go-humanize"
+ "github.com/olekukonko/tablewriter"
+ "github.com/shirou/gopsutil/process"
"github.com/spf13/cobra"
rr "github.com/spiral/roadrunner/cmd/rr/cmd"
+ "github.com/spiral/roadrunner/http"
rrpc "github.com/spiral/roadrunner/rpc"
"github.com/spiral/roadrunner/service"
- "github.com/spiral/roadrunner/http"
- "github.com/olekukonko/tablewriter"
+ "github.com/spiral/roadrunner/utils"
+ "net/rpc"
"os"
"strconv"
"time"
- "github.com/dustin/go-humanize"
- "github.com/spiral/roadrunner/cmd/rr/utils"
- "github.com/shirou/gopsutil/process"
- "net/rpc"
- tm "github.com/buger/goterm"
)
var (
diff --git a/cmd/rr/main.go b/cmd/rr/main.go
index ed47b2ed..6065d3d1 100644
--- a/cmd/rr/main.go
+++ b/cmd/rr/main.go
@@ -32,6 +32,7 @@ import (
// cli plugins
_ "github.com/spiral/roadrunner/cmd/rr/http"
+ "github.com/spiral/roadrunner/debug"
)
func main() {
@@ -44,6 +45,9 @@ func main() {
// serving static files
rr.Container.Register(static.Name, &static.Service{})
+ // provides additional verbosity
+ rr.Container.Register(debug.Name, &debug.Service{Logger: rr.Logger})
+
// you can register additional commands using cmd.CLI
rr.Execute()
}
diff --git a/cmd/rr/utils/config.go b/cmd/rr/utils/config.go
deleted file mode 100644
index 452dd195..00000000
--- a/cmd/rr/utils/config.go
+++ /dev/null
@@ -1,26 +0,0 @@
-package utils
-
-import (
- "github.com/spf13/viper"
- "github.com/spiral/roadrunner/service"
-)
-
-// ViperWrapper provides interface bridge between Viper configs and service.Config.
-type ViperWrapper struct {
- Viper *viper.Viper
-}
-
-// Get nested config section (sub-map), returns nil if section not found.
-func (w *ViperWrapper) Get(key string) service.Config {
- sub := w.Viper.Sub(key)
- if sub == nil {
- return nil
- }
-
- return &ViperWrapper{sub}
-}
-
-// Unmarshal unmarshal config data into given struct.
-func (w *ViperWrapper) Unmarshal(out interface{}) error {
- return w.Viper.Unmarshal(out)
-}
diff --git a/cmd/rr/utils/cprint.go b/cmd/rr/utils/cprint.go
deleted file mode 100644
index f6f828f8..00000000
--- a/cmd/rr/utils/cprint.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package utils
-
-import (
- "fmt"
- "gopkg.in/AlecAivazis/survey.v1/core"
- "regexp"
- "strings"
-)
-
-// Printf works identically to fmt.Print but adds `<white+hb>color formatting support for CLI</reset>`.
-func Printf(format string, args ...interface{}) {
- fmt.Print(Sprintf(format, args...))
-}
-
-// Sprintf works identically to fmt.Sprintf but adds `<white+hb>color formatting support for CLI</reset>`.
-func Sprintf(format string, args ...interface{}) string {
- r, err := regexp.Compile(`<([^>]+)>`)
- if err != nil {
- panic(err)
- }
-
- format = r.ReplaceAllStringFunc(format, func(s string) string {
- return fmt.Sprintf(`{{color "%s"}}`, strings.Trim(s, "<>/"))
- })
-
- out, err := core.RunTemplate(fmt.Sprintf(format, args...), nil)
- if err != nil {
- panic(err)
- }
-
- return out
-}