diff --git a/pkg/app2/appserver/proc.go b/pkg/app2/appserver/proc.go index 758312b0f7..bb1fb3a31d 100644 --- a/pkg/app2/appserver/proc.go +++ b/pkg/app2/appserver/proc.go @@ -2,6 +2,7 @@ package appserver import ( "fmt" + "io" "os/exec" "path/filepath" @@ -20,7 +21,7 @@ type Proc struct { } // NewProc constructs `Proc`. -func NewProc(log *logging.Logger, c Config, args []string) (*Proc, error) { +func NewProc(log *logging.Logger, c Config, args []string, stdout, stderr io.Writer) (*Proc, error) { key := GenerateAppKey() binaryPath := getBinaryPath(c.BinaryDir, c.Name, c.Version) @@ -39,6 +40,9 @@ func NewProc(log *logging.Logger, c Config, args []string) (*Proc, error) { cmd.Env = env cmd.Dir = c.WorkDir + cmd.Stdout = stdout + cmd.Stderr = stderr + rpcS, err := New(logging.MustGetLogger(fmt.Sprintf("app_rpc_server_%s", key)), c.SockFile, key) if err != nil { diff --git a/pkg/app2/appserver/proc_manager.go b/pkg/app2/appserver/proc_manager.go index c21532bd87..b96f4004e0 100644 --- a/pkg/app2/appserver/proc_manager.go +++ b/pkg/app2/appserver/proc_manager.go @@ -2,6 +2,7 @@ package appserver import ( "fmt" + "io" "os/exec" "sync" @@ -33,12 +34,13 @@ func NewProcManager(log *logging.Logger) *ProcManager { } // Run runs the application according to its config and additional args. -func (m *ProcManager) Run(log *logging.Logger, c Config, args []string) (apputil.ProcID, error) { +func (m *ProcManager) Run(log *logging.Logger, c Config, args []string, + stdout, stderr io.Writer) (apputil.ProcID, error) { if m.Exists(c.Name) { return 0, errAppAlreadyExists } - p, err := NewProc(log, c, args) + p, err := NewProc(log, c, args, stdout, stderr) if err != nil { return 0, err } diff --git a/pkg/visor/visor.go b/pkg/visor/visor.go index d526a83b8c..b7999db7d8 100644 --- a/pkg/visor/visor.go +++ b/pkg/visor/visor.go @@ -419,20 +419,15 @@ func (node *Node) SpawnApp(config *AppConfig, startCh chan<- struct{}) (err erro } // TODO: make PackageLogger return *RuleEntry. FieldLogger doesn't expose Writer. - /*logger := node.logger.WithField("_module", fmt.Sprintf("%s.v%s", config.App, config.Version)).Writer() + logger := node.logger.WithField("_module", fmt.Sprintf("%s.v%s", config.App, config.Version)).Writer() defer func() { if logErr := logger.Close(); err == nil && logErr != nil { err = logErr } }() - // TODO: pass this guy correctly - cmd.Stdout = logger - cmd.Stderr = logger - */ - pid, err := node.procManager.Run(logging.MustGetLogger(fmt.Sprintf("app_%s", config.App)), - appCfg, append([]string{filepath.Join(node.dir(), config.App)}, config.Args...)) + appCfg, append([]string{filepath.Join(node.dir(), config.App)}, config.Args...), logger, logger) if err != nil { return fmt.Errorf("error running app %s: %v", config.App, err) }