summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rr.yaml10
-rw-r--r--README.md22
-rw-r--r--service/metrics/rpc_test.go8
-rw-r--r--worker.go4
4 files changed, 40 insertions, 4 deletions
diff --git a/.rr.yaml b/.rr.yaml
index 7e38faf7..34ef7af7 100644
--- a/.rr.yaml
+++ b/.rr.yaml
@@ -13,11 +13,21 @@ rpc:
metrics:
# prometheus client address (path /metrics added automatically)
address: localhost:2112
+
+ # list of metrics to collect from application
collect:
+ # metric name
app_metric:
+ # type [gauge, counter, histogram, symnmary]
type: histogram
+
+ # short description
help: "Custom application metric"
+
+ # metric groups/tags
labels: ["type"]
+
+ # for histogram only
buckets: [0.1, 0.2, 0.3, 1.0]
# http service configuration.
diff --git a/README.md b/README.md
index 27be0208..967c11e2 100644
--- a/README.md
+++ b/README.md
@@ -47,11 +47,21 @@ Features:
- integrations with Symfony, Laravel, Slim, CakePHP, Zend Expressive, Spiral
- works on Windows
+Installation:
+--------
+To install:
+
+```
+$ composer require spiral/roadrunner
+$ ./vendor/bin/rr get-binary
+```
+
Example:
--------
```php
<?php
+// worker.php
ini_set('display_errors', 'stderr');
include "vendor/autoload.php";
@@ -75,11 +85,19 @@ Configuration can be located in `.rr.yaml` file ([full sample](https://github.co
```yaml
http:
address: 0.0.0.0:8080
- workers.command: "php psr-worker.php"
+ workers.command: "php worker.php"
```
> Read more in [Wiki](https://github.com/spiral/roadrunner/wiki/PHP-Workers).
+Run:
+----
+To run application server:
+
+```
+$ ./rr serve -v -d
+```
+
License:
--------
-The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [SpiralScout](https://spiralscout.com).
+The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [Spiral Scout](https://spiralscout.com).
diff --git a/service/metrics/rpc_test.go b/service/metrics/rpc_test.go
index 74b067c5..b7702311 100644
--- a/service/metrics/rpc_test.go
+++ b/service/metrics/rpc_test.go
@@ -7,10 +7,13 @@ import (
"github.com/spiral/roadrunner/service/rpc"
"github.com/stretchr/testify/assert"
rpc2 "net/rpc"
+ "strconv"
"testing"
"time"
)
+var port = 5004
+
func setup(t *testing.T, metric string) (*rpc2.Client, service.Container) {
logger, _ := test.NewNullLogger()
logger.SetLevel(logrus.DebugLevel)
@@ -20,7 +23,7 @@ func setup(t *testing.T, metric string) (*rpc2.Client, service.Container) {
c.Register(ID, &Service{})
assert.NoError(t, c.Init(&testCfg{
- rpcCfg: `{"enable":true, "listen":"tcp://:5004"}`,
+ rpcCfg: `{"enable":true, "listen":"tcp://:` + strconv.Itoa(port) + `"}`,
metricsCfg: `{
"address": "localhost:2112",
"collect":{
@@ -28,6 +31,9 @@ func setup(t *testing.T, metric string) (*rpc2.Client, service.Container) {
}
}`}))
+ // rotate ports for travis
+ port++
+
s, _ := c.Get(ID)
assert.NotNil(t, s)
diff --git a/worker.go b/worker.go
index ac0ba38e..a95a80b3 100644
--- a/worker.go
+++ b/worker.go
@@ -230,7 +230,9 @@ func (w *Worker) execPayload(rqs *Payload) (rsp *Payload, err error) {
return nil, errors.Wrap(err, "header error")
}
- w.rl.Send(rqs.Body, 0)
+ if err = w.rl.Send(rqs.Body, 0); err != nil {
+ return nil, errors.Wrap(err, "sender error")
+ }
var pr goridge.Prefix
rsp = new(Payload)