Introduce StartAfterFunc
This commit is contained in:
parent
d0696182e1
commit
30159d80b2
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user