diff options
author | Wolfy-J <[email protected]> | 2018-07-26 16:32:27 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-07-26 16:32:27 +0300 |
commit | bcef5b36bb50b2fecd4db4ca8e01640347300bea (patch) | |
tree | b6db6954063dd3288a80f24aa714e8799664d909 /server_config.go | |
parent | 0f8e2bab6888f1b27ed2bd1b91ac6b2677f03450 (diff) |
- added support for custom env provider
- new config section "env" to share env variables with php process
- container can resolve interfaces now
Diffstat (limited to 'server_config.go')
-rw-r--r-- | server_config.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/server_config.go b/server_config.go index b927c8c6..df9b4cee 100644 --- a/server_config.go +++ b/server_config.go @@ -2,6 +2,7 @@ package roadrunner import ( "errors" + "fmt" "net" "os/exec" "strings" @@ -26,6 +27,9 @@ 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 + + // Env defines set of values to be passed to the command context. + env []string } // Differs returns true if configuration has changed but ignores pool or cmd changes. @@ -33,11 +37,19 @@ func (cfg *ServerConfig) Differs(new *ServerConfig) bool { return cfg.Relay != new.Relay || cfg.RelayTimeout != new.RelayTimeout } +// SetEnv sets new environment variable. Value is automatically uppercase-d. +func (cfg *ServerConfig) SetEnv(k, v string) { + cfg.env = append(cfg.env, fmt.Sprintf("%s=%s", strings.ToUpper(k), v)) +} + // makeCommands returns new command provider based on configured options. func (cfg *ServerConfig) makeCommand() func() *exec.Cmd { var cmd = strings.Split(cfg.Command, " ") return func() *exec.Cmd { - return exec.Command(cmd[0], cmd[1:]...) + cmd := exec.Command(cmd[0], cmd[1:]...) + cmd.Env = cfg.env + + return cmd } } |