diff options
author | Wolfy-J <[email protected]> | 2018-07-26 16:56:25 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-07-26 16:56:25 +0300 |
commit | 234995f297c4067f4dfdba305f3b16a90143cf12 (patch) | |
tree | 48fca37b44593cfa969e3d55ba1e513576c25647 | |
parent | 0b170a3094aaa5f353550806ff409d67642225b9 (diff) |
handle env errors
-rw-r--r-- | cmd/rr/cmd/root.go | 4 | ||||
-rw-r--r-- | server_config.go | 1 | ||||
-rw-r--r-- | service/env/provider.go | 2 | ||||
-rw-r--r-- | service/env/service.go | 4 | ||||
-rw-r--r-- | service/http/service.go | 7 |
5 files changed, 11 insertions, 7 deletions
diff --git a/cmd/rr/cmd/root.go b/cmd/rr/cmd/root.go index 79f43398..595395c0 100644 --- a/cmd/rr/cmd/root.go +++ b/cmd/rr/cmd/root.go @@ -24,11 +24,11 @@ import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" + "github.com/spiral/roadrunner/cmd/rr/debug" "github.com/spiral/roadrunner/cmd/rr/utils" "github.com/spiral/roadrunner/service" - "os" "github.com/spiral/roadrunner/service/http" - "github.com/spiral/roadrunner/cmd/rr/debug" + "os" ) // Service bus for all the commands. diff --git a/server_config.go b/server_config.go index 3746f23f..b0680852 100644 --- a/server_config.go +++ b/server_config.go @@ -49,7 +49,6 @@ func (cfg *ServerConfig) makeCommand() func() *exec.Cmd { return func() *exec.Cmd { cmd := exec.Command(cmd[0], cmd[1:]...) cmd.Env = append(os.Environ(), cfg.env...) - return cmd } } diff --git a/service/env/provider.go b/service/env/provider.go index 75a1e31b..2918f18c 100644 --- a/service/env/provider.go +++ b/service/env/provider.go @@ -4,5 +4,5 @@ package env // values from external sources. type Provider interface { // GetEnv must return list of env variables. - GetEnv() map[string]string + GetEnv() (map[string]string, error) } diff --git a/service/env/service.go b/service/env/service.go index 95e99093..a90b0c48 100644 --- a/service/env/service.go +++ b/service/env/service.go @@ -16,6 +16,6 @@ func (s *Service) Init(cfg *Config) (bool, error) { } // GetEnv must return list of env variables. -func (s *Service) GetEnv() map[string]string { - return s.cfg.Values +func (s *Service) GetEnv() (map[string]string, error) { + return s.cfg.Values, nil } diff --git a/service/http/service.go b/service/http/service.go index a8f99669..9f62f5af 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -61,7 +61,12 @@ func (s *Service) Serve() error { s.mu.Lock() if s.env != nil { - for k, v := range s.env.GetEnv() { + values, err := s.env.GetEnv() + if err != nil { + return err + } + + for k, v := range values { s.cfg.Workers.SetEnv(k, v) } } |