diff options
author | Wolfy-J <[email protected]> | 2018-06-06 18:33:55 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-06 18:33:55 +0300 |
commit | 304b891eec532ca9d8c14f4c605493160a53370b (patch) | |
tree | 85256c64552e271a80b7cfe73eb49344f4cae607 /server_config.go | |
parent | acc86b65b75c26b0b3d730775acac44637b696b3 (diff) |
tests fixed for windows
Diffstat (limited to 'server_config.go')
-rw-r--r-- | server_config.go | 77 |
1 files changed, 1 insertions, 76 deletions
diff --git a/server_config.go b/server_config.go index 7e8aa80e..14bd7619 100644 --- a/server_config.go +++ b/server_config.go @@ -5,10 +5,6 @@ import ( "net" "strings" "time" - "os/exec" - "syscall" - "os/user" - "strconv" ) const ( @@ -18,18 +14,6 @@ const ( // 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 - - // User specifies what user to run command under, for Unix systems only. Support both UID and name options. Keep - // empty to use current user.This config section must not change on re-configuration. - User string - - // Group specifies what group to run command under, for Unix systems only. Support GID or name options. Keep empty - // to use current user.This config section must not change on re-configuration. - Group 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. @@ -41,74 +25,15 @@ type ServerConfig struct { // Pool defines worker pool configuration, number of workers, timeouts and etc. This config section might change // while server is running. - Pool *Config + Pool Config } // Differs returns true if configuration has changed but ignores pool changes. func (cfg *ServerConfig) Differs(new *ServerConfig) bool { - // command configuration has changed - if cfg.Command != new.Command || cfg.User != new.User || cfg.Group != new.Group { - return true - } - // factory configuration has changed return 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 ( - err error - u *user.User - g *user.Group - crd *syscall.Credential - cmd = strings.Split(cfg.Command, " ") - ) - - if cfg.User != "" { - if u, err = resolveUser(cfg.User); err != nil { - return nil, err - } - } - - if cfg.Group != "" { - if g, err = resolveGroup(cfg.Group); err != nil { - return nil, err - } - } - - if u != nil || g != nil { - crd = &syscall.Credential{} - - if u != nil { - uid, err := strconv.ParseUint(u.Uid, 10, 32) - if err != nil { - return nil, err - } - - crd.Uid = uint32(uid) - } - - if g != nil { - gid, err := strconv.ParseUint(g.Gid, 10, 32) - if err != nil { - return nil, err - } - - crd.Gid = uint32(gid) - } - } - - return func() *exec.Cmd { - cmd := exec.Command(cmd[0], cmd[1:]...) - if crd != nil { - cmd.SysProcAttr = &syscall.SysProcAttr{Credential: crd} - } - - return cmd - }, 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" { |