summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpipe_factory.go4
-rw-r--r--plugins/http/plugin.go3
-rw-r--r--plugins/server/tests/server_test.go4
-rwxr-xr-xsocket_factory.go30
4 files changed, 19 insertions, 22 deletions
diff --git a/pipe_factory.go b/pipe_factory.go
index 76a3780e..e59055b4 100755
--- a/pipe_factory.go
+++ b/pipe_factory.go
@@ -70,7 +70,7 @@ func (f *PipeFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cmd)
if err != nil {
c <- SpawnResult{
w: nil,
- err: errors.E(op, err, "process error"),
+ err: errors.E(op, err),
}
return
}
@@ -137,7 +137,7 @@ func (f *PipeFactory) SpawnWorker(cmd *exec.Cmd) (WorkerBase, error) {
// Start the worker
err = w.Start()
if err != nil {
- return nil, errors.E(op, err, "process error")
+ return nil, errors.E(op, err)
}
// errors bundle
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 581455b3..e5ccabc4 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -18,6 +18,7 @@ import (
"github.com/spiral/roadrunner/v2/interfaces/log"
factory "github.com/spiral/roadrunner/v2/interfaces/server"
"github.com/spiral/roadrunner/v2/plugins/config"
+ "github.com/spiral/roadrunner/v2/plugins/http/attributes"
"github.com/spiral/roadrunner/v2/util"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
@@ -272,7 +273,7 @@ func (s *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload")
}
- //r = attributes.Init(r)
+ r = attributes.Init(r)
// chaining middleware
f := s.handler.ServeHTTP
diff --git a/plugins/server/tests/server_test.go b/plugins/server/tests/server_test.go
index f917df5d..bc374a9e 100644
--- a/plugins/server/tests/server_test.go
+++ b/plugins/server/tests/server_test.go
@@ -273,9 +273,7 @@ func TestAppWrongRelay(t *testing.T) {
}
err = container.Init()
- if err != nil {
- t.Fatal(err)
- }
+ assert.Error(t, err)
_, err = container.Serve()
assert.Error(t, err)
diff --git a/socket_factory.go b/socket_factory.go
index 6f29db22..87b3f924 100755
--- a/socket_factory.go
+++ b/socket_factory.go
@@ -4,13 +4,12 @@ import (
"context"
"net"
"os/exec"
- "strings"
"sync"
"time"
"github.com/shirou/gopsutil/process"
+ "github.com/spiral/errors"
- "github.com/pkg/errors"
"github.com/spiral/goridge/v2"
"go.uber.org/multierr"
"golang.org/x/sync/errgroup"
@@ -83,6 +82,7 @@ type socketSpawn struct {
// SpawnWorker creates WorkerProcess and connects it to appropriate relay or returns error
func (f *SocketFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cmd) (WorkerBase, error) {
+ const op = errors.Op("spawn_worker_with_context")
c := make(chan socketSpawn)
go func() {
ctx, cancel := context.WithTimeout(ctx, f.tout)
@@ -100,7 +100,7 @@ func (f *SocketFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cm
if err != nil {
c <- socketSpawn{
w: nil,
- err: errors.Wrap(err, "process error"),
+ err: errors.E(op, err),
}
return
}
@@ -115,7 +115,7 @@ func (f *SocketFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cm
c <- socketSpawn{
w: nil,
- err: err,
+ err: errors.E(op, err),
}
return
}
@@ -144,6 +144,7 @@ func (f *SocketFactory) SpawnWorkerWithContext(ctx context.Context, cmd *exec.Cm
func (f *SocketFactory) SpawnWorker(cmd *exec.Cmd) (WorkerBase, error) {
ctx := context.Background()
+ const op = errors.Op("spawn_worker")
w, err := InitBaseWorker(cmd)
if err != nil {
return nil, err
@@ -151,21 +152,17 @@ func (f *SocketFactory) SpawnWorker(cmd *exec.Cmd) (WorkerBase, error) {
err = w.Start()
if err != nil {
- return nil, errors.Wrap(err, "process error")
+ return nil, errors.E(op, err)
}
- var errs []string
rl, err := f.findRelay(w)
if err != nil {
- errs = append(errs, err.Error())
- err = w.Kill()
- if err != nil {
- errs = append(errs, err.Error())
- }
- if err = w.Wait(ctx); err != nil {
- errs = append(errs, err.Error())
- }
- return nil, errors.New(strings.Join(errs, "/"))
+ err = multierr.Combine(
+ err,
+ w.Kill(),
+ w.Wait(ctx),
+ )
+ return nil, err
}
w.AttachRelay(rl)
@@ -202,12 +199,13 @@ func (f *SocketFactory) findRelayWithContext(ctx context.Context, w WorkerBase)
}
func (f *SocketFactory) findRelay(w WorkerBase) (*goridge.SocketRelay, error) {
+ const op = errors.Op("find_relay")
// poll every 1ms for the relay
pollDone := time.NewTimer(f.tout)
for {
select {
case <-pollDone.C:
- return nil, errors.New("relay timeout")
+ return nil, errors.E(op, errors.Str("relay timeout"))
default:
tmp, ok := f.relays.Load(w.Pid())
if !ok {