summaryrefslogtreecommitdiff
path: root/cmd/rr
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-07-09 11:08:41 -0700
committerWolfy-J <[email protected]>2018-07-09 11:08:41 -0700
commitc7f3509ce37fcda22956a2d74c322ab84e23ea6c (patch)
tree472b95a4f18b34dbd10a80e0cdafc31b22f296d8 /cmd/rr
parent07e407e71bbc754fe1bc6dcff38cc0970509216d (diff)
debug mode moved to default cmd
Diffstat (limited to 'cmd/rr')
-rw-r--r--cmd/rr/cmd/root.go14
-rw-r--r--cmd/rr/main.go25
2 files changed, 13 insertions, 26 deletions
diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go
index 1a21cfc9..60fa79df 100644
--- a/cmd/rr/cmd/root.go
+++ b/cmd/rr/cmd/root.go
@@ -27,12 +27,14 @@ import (
"github.com/spiral/roadrunner/cmd/rr/utils"
"github.com/spiral/roadrunner/service"
"os"
+ "github.com/spiral/roadrunner/service/http"
+ "github.com/spiral/roadrunner/cmd/rr/debug"
)
// Service bus for all the commands.
var (
- cfgFile string
- verbose bool
+ cfgFile string
+ verbose, debugMode bool
// Logger - shared logger.
Logger = logrus.New()
@@ -83,7 +85,10 @@ func Execute() {
}
func init() {
+ Logger.Formatter = &logrus.TextFormatter{ForceColors: true}
+
CLI.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
+ CLI.PersistentFlags().BoolVarP(&debugMode, "debug", "d", false, "debug mode")
CLI.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is .rr.yaml)")
cobra.OnInitialize(func() {
@@ -91,6 +96,11 @@ func init() {
Logger.SetLevel(logrus.DebugLevel)
}
+ if debugMode {
+ svc, _ := Container.Get(http.ID)
+ svc.(*http.Service).AddListener(debug.Listener(Logger))
+ }
+
if cfg := initConfig(cfgFile, []string{"."}, ".rr"); cfg != nil {
if err := Container.Init(cfg); err != nil {
utils.Printf("<red+hb>Error:</reset> <red>%s</reset>\n", err)
diff --git a/cmd/rr/main.go b/cmd/rr/main.go
index 03bef9bd..4d66177a 100644
--- a/cmd/rr/main.go
+++ b/cmd/rr/main.go
@@ -30,38 +30,15 @@ import (
"github.com/spiral/roadrunner/service/rpc"
"github.com/spiral/roadrunner/service/static"
- // cli plugins
- "github.com/spiral/roadrunner/cmd/rr/debug"
+ // additional command handlers
_ "github.com/spiral/roadrunner/cmd/rr/http"
-
- "github.com/sirupsen/logrus"
- "github.com/spf13/cobra"
)
-var debugMode bool
-
func main() {
- // forcing text based logging
- rr.Logger.Formatter = &logrus.TextFormatter{ForceColors: true}
-
- // provides ability to make local connection to services
rr.Container.Register(rpc.ID, &rpc.Service{})
-
- // http serving
rr.Container.Register(http.ID, &http.Service{})
-
- // serving static files
rr.Container.Register(static.ID, &static.Service{})
- // debug mode
- rr.CLI.PersistentFlags().BoolVarP(&debugMode, "debug", "d", false, "debug mode")
- cobra.OnInitialize(func() {
- if debugMode {
- service, _ := rr.Container.Get(http.ID)
- service.(*http.Service).AddListener(debug.Listener(rr.Logger))
- }
- })
-
// you can register additional commands using cmd.CLI
rr.Execute()
}