summaryrefslogtreecommitdiff
path: root/server_config.go
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-10 13:14:44 +0300
committerWolfy-J <[email protected]>2018-06-10 13:14:44 +0300
commitdc56d924ac34252f1866dd067a9e80c30b0d133c (patch)
treeeefe5c9001cabc4455d8eed55a91e37fe6293a84 /server_config.go
parentd4c007859c002e6af540ec516929de81d03ff82d (diff)
working with more tests and isolated command
Diffstat (limited to 'server_config.go')
-rw-r--r--server_config.go23
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" {