diff options
-rw-r--r-- | cmd/rr/cmd/root.go | 14 | ||||
-rw-r--r-- | cmd/rr/main.go | 25 | ||||
-rw-r--r-- | service/rpc/config.go | 4 |
3 files changed, 13 insertions, 30 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() } diff --git a/service/rpc/config.go b/service/rpc/config.go index c37b0853..93fce7ca 100644 --- a/service/rpc/config.go +++ b/service/rpc/config.go @@ -32,10 +32,6 @@ func (c *Config) Valid() error { return errors.New("invalid socket DSN (tcp://:6001, unix://rpc.sock)") } - if dsn := strings.Split(c.Listen, "://"); len(dsn) != 2 { - return errors.New("invalid socket DSN (tcp://:6001, unix://rpc.sock)") - } - return nil } |