summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-03 13:08:48 +0300
committerWolfy-J <[email protected]>2018-06-03 13:08:48 +0300
commitf363040a9a72d53b4d5f0ffbf40773a27e9bd98f (patch)
tree89fcde37773d2a5fd394c1149b308a0096ed2820
parent00eaa539e333184bdfb73fe3347bc5358de8a551 (diff)
CS
-rw-r--r--cmd/rr/cmd/root.go14
-rw-r--r--cmd/rr/cmd/serve.go2
-rw-r--r--cmd/rr/http/register.go13
-rw-r--r--cmd/rr/http/reload.go8
-rw-r--r--cmd/rr/http/workers.go8
-rw-r--r--cmd/rr/main.go2
6 files changed, 22 insertions, 25 deletions
diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go
index 23498018..e9351e75 100644
--- a/cmd/rr/cmd/root.go
+++ b/cmd/rr/cmd/root.go
@@ -35,8 +35,8 @@ var (
// Shared service bus.
Services = service.NewBus()
- // Root is application endpoint.
- Root = &cobra.Command{
+ // CLI is application endpoint.
+ CLI = &cobra.Command{
Use: "rr",
Short: "RoadRunner, PHP application server",
}
@@ -45,18 +45,18 @@ var (
verbose bool
)
-// Execute adds all child commands to the Root command and sets flags appropriately.
-// This is called by main.main(). It only needs to happen once to the Root.
+// 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() {
- if err := Root.Execute(); err != nil {
+ if err := CLI.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
- Root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
- Root.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is .rr.yaml)")
+ CLI.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
+ CLI.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is .rr.yaml)")
cobra.OnInitialize(func() {
if verbose {
diff --git a/cmd/rr/cmd/serve.go b/cmd/rr/cmd/serve.go
index 7d982128..17409411 100644
--- a/cmd/rr/cmd/serve.go
+++ b/cmd/rr/cmd/serve.go
@@ -32,7 +32,7 @@ var (
)
func init() {
- Root.AddCommand(&cobra.Command{
+ CLI.AddCommand(&cobra.Command{
Use: "serve",
Short: "Serve RoadRunner service(s)",
Run: serveHandler,
diff --git a/cmd/rr/http/register.go b/cmd/rr/http/register.go
index b8447ed4..a725f5f2 100644
--- a/cmd/rr/http/register.go
+++ b/cmd/rr/http/register.go
@@ -3,8 +3,21 @@ package http
import (
rr "github.com/spiral/roadrunner/cmd/rr/cmd"
"github.com/spiral/roadrunner/http"
+ "github.com/spf13/cobra"
)
func init() {
rr.Services.Register(&http.Service{})
+
+ rr.CLI.AddCommand(&cobra.Command{
+ Use: "http:reload",
+ Short: "Reload RoadRunner worker pools for the HTTP service",
+ Run: reloadHandler,
+ })
+
+ rr.CLI.AddCommand(&cobra.Command{
+ Use: "http:workers",
+ Short: "List workers associated with RoadRunner HTTP service",
+ Run: workersHandler,
+ })
}
diff --git a/cmd/rr/http/reload.go b/cmd/rr/http/reload.go
index 4bd847c3..89c0b74b 100644
--- a/cmd/rr/http/reload.go
+++ b/cmd/rr/http/reload.go
@@ -26,14 +26,6 @@ import (
rr "github.com/spiral/roadrunner/cmd/rr/cmd"
)
-func init() {
- rr.Root.AddCommand(&cobra.Command{
- Use: "http:reload",
- Short: "Reload RoadRunner worker pools for the HTTP service",
- Run: reloadHandler,
- })
-}
-
func reloadHandler(cmd *cobra.Command, args []string) {
client, err := rr.Services.RCPClient()
if err != nil {
diff --git a/cmd/rr/http/workers.go b/cmd/rr/http/workers.go
index fb34d0b5..19fc6df8 100644
--- a/cmd/rr/http/workers.go
+++ b/cmd/rr/http/workers.go
@@ -29,14 +29,6 @@ import (
"strconv"
)
-func init() {
- rr.Root.AddCommand(&cobra.Command{
- Use: "http:workers",
- Short: "List workers associated with RoadRunner HTTP service",
- Run: workersHandler,
- })
-}
-
func workersHandler(cmd *cobra.Command, args []string) {
client, err := rr.Services.RCPClient()
if err != nil {
diff --git a/cmd/rr/main.go b/cmd/rr/main.go
index 4d132da6..9d6f685c 100644
--- a/cmd/rr/main.go
+++ b/cmd/rr/main.go
@@ -30,6 +30,6 @@ import (
)
func main() {
- // you can register additional commands using cmd.Root
+ // you can register additional commands using cmd.CLI
cmd.Execute()
}