summaryrefslogtreecommitdiff
path: root/cmd/rr
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/rr')
-rw-r--r--cmd/rr/.rr.yaml23
-rw-r--r--cmd/rr/cmd/root.go13
-rw-r--r--cmd/rr/cmd/stop.go52
-rw-r--r--cmd/rr/http/reset.go2
-rw-r--r--cmd/rr/main.go2
5 files changed, 89 insertions, 3 deletions
diff --git a/cmd/rr/.rr.yaml b/cmd/rr/.rr.yaml
index f50ff0e9..9cdde098 100644
--- a/cmd/rr/.rr.yaml
+++ b/cmd/rr/.rr.yaml
@@ -29,7 +29,7 @@ http:
key: server.key
# max POST request size, including file uploads in MB.
- maxRequest: 200
+ maxRequestSize: 200
# file upload configuration.
uploads:
@@ -58,6 +58,27 @@ http:
# amount of time given to worker to gracefully destruct itself.
destroyTimeout: 60
+# monitors roadrunner server(s)
+watch:
+ # check worker state each second
+ interval: 1
+
+ # custom watch configuration for each service
+ services:
+ # monitor http workers
+ http:
+ # maximum allowed memory consumption
+ maxMemory: 100
+
+ # maximum time to live for the worker
+ maxTTL: 0
+
+ # maximum allowed amount of time worker can spend in idle before being removed (for weak db connections)
+ maxIdleTTL: 0
+
+ # max_execution_time, worker will be killed if that amount of time spend for task execution
+ maxExecTTL: 60
+
# static file serving. remove this section to disable static file serving.
static:
# root directory for static file (http would not serve .php and .htaccess files).
diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go
index 74506004..1222177a 100644
--- a/cmd/rr/cmd/root.go
+++ b/cmd/rr/cmd/root.go
@@ -25,10 +25,11 @@ import (
"github.com/spf13/cobra"
"github.com/spiral/roadrunner/cmd/util"
"github.com/spiral/roadrunner/service"
+ "github.com/spiral/roadrunner/service/watcher"
"os"
)
-// Service bus for all the commands.
+// Services bus for all the commands.
var (
cfgFile, workDir, logFormat string
override []string
@@ -106,6 +107,16 @@ func init() {
util.Printf("<red+hb>Error:</reset> <red>%s</reset>\n", err)
os.Exit(1)
}
+
+ // global watcher config
+ if Verbose {
+ wcv, _ := Container.Get(watcher.ID)
+ if wcv, ok := wcv.(*watcher.Service); ok {
+ wcv.AddListener(func(event int, ctx interface{}) {
+ util.LogEvent(Logger, event, ctx)
+ })
+ }
+ }
})
}
diff --git a/cmd/rr/cmd/stop.go b/cmd/rr/cmd/stop.go
new file mode 100644
index 00000000..2f48615b
--- /dev/null
+++ b/cmd/rr/cmd/stop.go
@@ -0,0 +1,52 @@
+// Copyright (c) 2018 SpiralScout
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+package cmd
+
+import (
+ "github.com/spf13/cobra"
+ "github.com/spiral/roadrunner/cmd/util"
+)
+
+func init() {
+ CLI.AddCommand(&cobra.Command{
+ Use: "stop",
+ Short: "Detach RoadRunner server",
+ RunE: stopHandler,
+ })
+}
+
+func stopHandler(cmd *cobra.Command, args []string) error {
+ client, err := util.RPCClient(Container)
+ if err != nil {
+ return err
+ }
+ defer client.Close()
+
+ util.Printf("<green>Stopping RoadRunner</reset>: ")
+
+ var r string
+ if err := client.Call("system.Detach", true, &r); err != nil {
+ return err
+ }
+
+ util.Printf("<green+hb>done</reset>\n")
+ return nil
+}
diff --git a/cmd/rr/http/reset.go b/cmd/rr/http/reset.go
index 42fd966d..3008848a 100644
--- a/cmd/rr/http/reset.go
+++ b/cmd/rr/http/reset.go
@@ -41,7 +41,7 @@ func reloadHandler(cmd *cobra.Command, args []string) error {
}
defer client.Close()
- util.Printf("<green>restarting http worker pool</reset>: ")
+ util.Printf("<green>Restarting http worker pool</reset>: ")
var r string
if err := client.Call("http.Reset", true, &r); err != nil {
diff --git a/cmd/rr/main.go b/cmd/rr/main.go
index 54915957..dc2fbc20 100644
--- a/cmd/rr/main.go
+++ b/cmd/rr/main.go
@@ -24,6 +24,7 @@ package main
import (
rr "github.com/spiral/roadrunner/cmd/rr/cmd"
+ "github.com/spiral/roadrunner/service/watcher"
// services (plugins)
"github.com/spiral/roadrunner/service/env"
@@ -40,6 +41,7 @@ func main() {
rr.Container.Register(rpc.ID, &rpc.Service{})
rr.Container.Register(http.ID, &http.Service{})
rr.Container.Register(static.ID, &static.Service{})
+ rr.Container.Register(watcher.ID, &watcher.Service{})
// you can register additional commands using cmd.CLI
rr.Execute()