Merge pull request #1751 from smallstep/herman/handle-server-startup-errors

Handle CA server startup errors
pull/1753/head
Herman Slatman 3 months ago committed by GitHub
commit a7a4b47ead
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -476,6 +476,20 @@ func (ca *CA) Run() error {
// wait till error occurs; ensures the servers keep listening
err := <-errs
// if the error is not the usual HTTP server closed error, it is
// highly likely that an error occurred when starting one of the
// CA servers, possibly because of a port already being in use or
// some part of the configuration not being correct. This case is
// handled by stopping the CA in its entirety.
if !errors.Is(err, http.ErrServerClosed) {
log.Println("shutting down due to startup error ...")
if stopErr := ca.Stop(); stopErr != nil {
err = fmt.Errorf("failed stopping CA after error occurred: %w: %w", err, stopErr)
} else {
err = fmt.Errorf("stopped CA after error occurred: %w", err)
}
}
wg.Wait()
return err

Loading…
Cancel
Save