diff options
-rw-r--r-- | server_config.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/server_config.go b/server_config.go index ad708e10..d7c27c4a 100644 --- a/server_config.go +++ b/server_config.go @@ -5,15 +5,15 @@ import ( "net" "strings" "time" -) - -const ( - FactoryPipes = iota - FactorySocket + "os/exec" ) // Server config combines factory, pool and cmd configurations. type ServerConfig struct { + // Command includes command strings with all the parameters, example: "php worker.php pipes". This config section + // must not change on re-configuration. + Command string + // Relay 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. @@ -28,6 +28,19 @@ type ServerConfig struct { Pool Config } +// Differs returns true if configuration has changed but ignores pool changes. +func (cfg *ServerConfig) Differs(new *ServerConfig) bool { + return cfg.Command != new.Command || cfg.Relay != new.Relay || cfg.RelayTimeout != new.RelayTimeout +} + +// makeCommands returns new command provider based on configured options. +func (cfg *ServerConfig) makeCommand() (func() *exec.Cmd, error) { + var cmd = strings.Split(cfg.Command, " ") + return func() *exec.Cmd { + return exec.Command(cmd[0], cmd[1:]...) + }, nil +} + // makeFactory creates and connects new factory instance based on given parameters. func (cfg *ServerConfig) makeFactory() (Factory, error) { if cfg.Relay == "pipes" || cfg.Relay == "pipe" { |