summaryrefslogtreecommitdiff
path: root/transport
diff options
context:
space:
mode:
Diffstat (limited to 'transport')
-rwxr-xr-xtransport/pipe/pipe_factory.go36
-rwxr-xr-xtransport/socket/socket_factory.go32
2 files changed, 20 insertions, 48 deletions
diff --git a/transport/pipe/pipe_factory.go b/transport/pipe/pipe_factory.go
index 84a9d311..3ea8fd98 100755
--- a/transport/pipe/pipe_factory.go
+++ b/transport/pipe/pipe_factory.go
@@ -4,12 +4,10 @@ import (
"context"
"os/exec"
- "github.com/spiral/errors"
"github.com/spiral/goridge/v3/pkg/pipe"
"github.com/spiral/roadrunner/v2/events"
"github.com/spiral/roadrunner/v2/internal"
"github.com/spiral/roadrunner/v2/worker"
- "go.uber.org/multierr"
)
// Factory connects to stack using standard
@@ -31,14 +29,13 @@ type sr struct {
// method Wait() must be handled on level above.
func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, listeners ...events.Listener) (*worker.Process, error) {
spCh := make(chan sr)
- const op = errors.Op("factory_spawn_worker_with_timeout")
go func() {
w, err := worker.InitBaseWorker(cmd, worker.AddListeners(listeners...))
if err != nil {
select {
case spCh <- sr{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
default:
@@ -51,7 +48,7 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
select {
case spCh <- sr{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
default:
@@ -64,7 +61,7 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
select {
case spCh <- sr{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
default:
@@ -82,7 +79,7 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
select {
case spCh <- sr{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
default:
@@ -93,15 +90,11 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
// used as a ping
_, err = internal.Pid(relay)
if err != nil {
- err = multierr.Combine(
- err,
- w.Kill(),
- w.Wait(),
- )
+ _ = w.Kill()
select {
case spCh <- sr{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
default:
@@ -138,20 +131,19 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
}
func (f *Factory) SpawnWorker(cmd *exec.Cmd, listeners ...events.Listener) (*worker.Process, error) {
- const op = errors.Op("factory_spawn_worker")
w, err := worker.InitBaseWorker(cmd, worker.AddListeners(listeners...))
if err != nil {
- return nil, errors.E(op, err)
+ return nil, err
}
in, err := cmd.StdoutPipe()
if err != nil {
- return nil, errors.E(op, err)
+ return nil, err
}
out, err := cmd.StdinPipe()
if err != nil {
- return nil, errors.E(op, err)
+ return nil, err
}
// Init new PIPE relay
@@ -161,18 +153,14 @@ func (f *Factory) SpawnWorker(cmd *exec.Cmd, listeners ...events.Listener) (*wor
// Start the worker
err = w.Start()
if err != nil {
- return nil, errors.E(op, err)
+ return nil, err
}
// errors bundle
_, err = internal.Pid(relay)
if err != nil {
- err = multierr.Combine(
- err,
- w.Kill(),
- w.Wait(),
- )
- return nil, errors.E(op, err)
+ _ = w.Kill()
+ return nil, err
}
// everything ok, set ready state
diff --git a/transport/socket/socket_factory.go b/transport/socket/socket_factory.go
index 39c04eac..dfffdf4e 100755
--- a/transport/socket/socket_factory.go
+++ b/transport/socket/socket_factory.go
@@ -16,7 +16,6 @@ import (
"github.com/spiral/roadrunner/v2/internal"
"github.com/spiral/roadrunner/v2/worker"
- "go.uber.org/multierr"
"golang.org/x/sync/errgroup"
)
@@ -85,7 +84,6 @@ type socketSpawn struct {
// SpawnWorkerWithTimeout creates Process and connects it to appropriate relay or return an error
func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, listeners ...events.Listener) (*worker.Process, error) {
- const op = errors.Op("factory_spawn_worker_with_timeout")
c := make(chan socketSpawn)
go func() {
ctxT, cancel := context.WithTimeout(ctx, f.tout)
@@ -95,7 +93,7 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
select {
case c <- socketSpawn{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
default:
@@ -108,7 +106,7 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
select {
case c <- socketSpawn{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
default:
@@ -118,17 +116,12 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
rl, err := f.findRelayWithContext(ctxT, w)
if err != nil {
- err = multierr.Combine(
- err,
- w.Kill(),
- w.Wait(),
- )
-
+ _ = w.Kill()
select {
// try to write result
case c <- socketSpawn{
w: nil,
- err: errors.E(op, err),
+ err: err,
}:
return
// if no receivers - return
@@ -165,7 +158,6 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd, lis
}
func (f *Factory) SpawnWorker(cmd *exec.Cmd, listeners ...events.Listener) (*worker.Process, error) {
- const op = errors.Op("factory_spawn_worker")
w, err := worker.InitBaseWorker(cmd, worker.AddListeners(listeners...))
if err != nil {
return nil, err
@@ -173,16 +165,12 @@ func (f *Factory) SpawnWorker(cmd *exec.Cmd, listeners ...events.Listener) (*wor
err = w.Start()
if err != nil {
- return nil, errors.E(op, err)
+ return nil, err
}
rl, err := f.findRelay(w)
if err != nil {
- err = multierr.Combine(
- err,
- w.Kill(),
- w.Wait(),
- )
+ _ = w.Kill()
return nil, err
}
@@ -191,12 +179,8 @@ func (f *Factory) SpawnWorker(cmd *exec.Cmd, listeners ...events.Listener) (*wor
// errors bundle
_, err = internal.Pid(rl)
if err != nil {
- err = multierr.Combine(
- err,
- w.Kill(),
- w.Wait(),
- )
- return nil, errors.E(op, err)
+ _ = w.Kill()
+ return nil, err
}
w.State().Set(worker.StateReady)