// done enough to satisfy a dependency relationship (e.g., the
// service is running and ready). If the task starts a
// goroutine that fails after Run returns (e.g., the service
- // shuts down), it should call cancel.
+ // shuts down), it should call fail().
Run(ctx context.Context, fail func(error), super *Supervisor) error
String() string
}
super.Start(ctx, cfg)
defer super.Stop()
- if url, ok := super.WaitReady(); ok {
- fmt.Fprintln(stdout, url)
- // Wait for signal/crash + orderly shutdown
- <-super.done
- return 0
- } else {
+ url, ok := super.WaitReady()
+ if !ok {
return 1
}
+ // Write controller URL to stdout. Nothing else goes to
+ // stdout, so this provides an easy way for a calling script
+ // to discover the controller URL when everything is ready.
+ fmt.Fprintln(stdout, url)
+ // Wait for signal/crash + orderly shutdown
+ <-super.done
+ return 0
}