From 6f7e126d6ea25c83b4df50048d1073c6e76ff338 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Sat, 17 Oct 2020 17:31:27 +0300 Subject: - fixes pipe relay initialization --- plugins/factory/app.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/factory/app.go b/plugins/factory/app.go index a38307e7..3de572b0 100644 --- a/plugins/factory/app.go +++ b/plugins/factory/app.go @@ -20,11 +20,10 @@ type AppConfig struct { Group string Env Env - Relay string // Listen defines connection method and factory to be used to connect to workers: // "pipes", "tcp://:6001", "unix://rr.sock" // This config section must not change on re-configuration. - Listen string + Relay string // RelayTimeout defines for how long socket factory will be waiting for worker connection. This config section // must not change on re-configuration. @@ -82,25 +81,28 @@ func (app *App) NewCmd(env Env) (func() *exec.Cmd, error) { // todo ENV unused func (app *App) NewFactory(env Env) (roadrunner.Factory, error) { - lsn, err := util.CreateListener(app.cfg.Listen) - if err != nil { - return nil, err + if app.cfg.Relay == "" || app.cfg.Relay == "pipes" { + return roadrunner.NewPipeFactory(), nil } - dsn := strings.Split(app.cfg.Listen, "://") - if app.cfg.Listen != "" && len(dsn) != 2 { + dsn := strings.Split(app.cfg.Relay, "://") + if len(dsn) != 2 { return nil, errors.New("invalid DSN (tcp://:6001, unix://file.sock)") } + lsn, err := util.CreateListener(app.cfg.Relay) + if err != nil { + return nil, err + } + switch dsn[0] { // sockets group case "unix": return roadrunner.NewSocketServer(lsn, app.cfg.RelayTimeout), nil case "tcp": return roadrunner.NewSocketServer(lsn, app.cfg.RelayTimeout), nil - // pipes default: - return roadrunner.NewPipeFactory(), nil + return nil, errors.New("invalid DSN (tcp://:6001, unix://file.sock)") } } -- cgit v1.2.3