diff --git a/pmuxlib/proc.go b/pmuxlib/proc.go index 54e89c2..2e91d9d 100644 --- a/pmuxlib/proc.go +++ b/pmuxlib/proc.go @@ -48,6 +48,11 @@ type ProcessConfig struct { // NoRestartOn indicates which exit codes should result in the process not // being restarted any further. NoRestartOn []int `yaml:"noRestartOn"` + + // StartAfterFunc will cause the starting of the process to be blocked until + // this function returns. If used with RunProcessOnce and an error is + // returned, RunProcessOnce will return that error. + StartAfterFunc func(context.Context) error } func (cfg ProcessConfig) withDefaults() ProcessConfig { @@ -104,6 +109,12 @@ func RunProcessOnce( cfg = cfg.withDefaults() + if cfg.StartAfterFunc != nil { + if err := cfg.StartAfterFunc(ctx); err != nil { + return -1, err + } + } + var wg sync.WaitGroup fwdOutPipe := func(logger Logger, r io.Reader) {