summaryrefslogtreecommitdiff
path: root/pkg/socket
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/socket')
-rwxr-xr-xpkg/socket/socket_factory.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/pkg/socket/socket_factory.go b/pkg/socket/socket_factory.go
index 49456bd9..a3a0bf18 100755
--- a/pkg/socket/socket_factory.go
+++ b/pkg/socket/socket_factory.go
@@ -11,6 +11,7 @@ import (
"github.com/spiral/errors"
"github.com/spiral/goridge/v3/interfaces/relay"
"github.com/spiral/goridge/v3/pkg/socket"
+ "github.com/spiral/roadrunner/v2/interfaces/events"
"github.com/spiral/roadrunner/v2/interfaces/worker"
"github.com/spiral/roadrunner/v2/internal"
workerImpl "github.com/spiral/roadrunner/v2/pkg/worker"
@@ -24,6 +25,9 @@ type Factory struct {
// listens for incoming connections from underlying processes
ls net.Listener
+ // events listener
+ listeners []events.EventListener
+
// relay connection timeout
tout time.Duration
@@ -38,12 +42,13 @@ type Factory struct {
// NewSocketServer returns Factory attached to a given socket listener.
// tout specifies for how long factory should serve for incoming relay connection
-func NewSocketServer(ls net.Listener, tout time.Duration) worker.Factory {
+func NewSocketServer(ls net.Listener, tout time.Duration, listeners ...events.EventListener) worker.Factory {
f := &Factory{
- ls: ls,
- tout: tout,
- relays: sync.Map{},
- ErrCh: make(chan error, 10),
+ ls: ls,
+ tout: tout,
+ relays: sync.Map{},
+ listeners: listeners,
+ ErrCh: make(chan error, 10),
}
// Be careful
@@ -91,7 +96,7 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd) (wo
go func() {
ctx, cancel := context.WithTimeout(ctx, f.tout)
defer cancel()
- w, err := workerImpl.InitBaseWorker(cmd)
+ w, err := workerImpl.InitBaseWorker(cmd, workerImpl.AddListeners(f.listeners...))
if err != nil {
c <- socketSpawn{
w: nil,
@@ -147,7 +152,7 @@ func (f *Factory) SpawnWorkerWithTimeout(ctx context.Context, cmd *exec.Cmd) (wo
func (f *Factory) SpawnWorker(cmd *exec.Cmd) (worker.BaseProcess, error) {
const op = errors.Op("spawn_worker")
- w, err := workerImpl.InitBaseWorker(cmd)
+ w, err := workerImpl.InitBaseWorker(cmd, workerImpl.AddListeners(f.listeners...))
if err != nil {
return nil, err
}