acme solver wait for server to shutdown
Signed-off-by: Inteon <42113979+inteon@users.noreply.github.com>
This commit is contained in:
parent
769e057663
commit
f11c44dd15
@ -18,6 +18,7 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@ -37,9 +38,15 @@ func NewACMESolverCommand(stopCh <-chan struct{}) *cobra.Command {
|
||||
rootCtx = logf.NewContext(rootCtx, nil, "acmesolver")
|
||||
log := logf.FromContext(rootCtx)
|
||||
|
||||
completedCh := make(chan struct{})
|
||||
go func() {
|
||||
defer close(completedCh)
|
||||
<-stopCh
|
||||
if err := s.Shutdown(rootCtx); err != nil {
|
||||
// allow a timeout for graceful shutdown
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
|
||||
if err := s.Shutdown(ctx); err != nil {
|
||||
log.Error(err, "error shutting down acmesolver server")
|
||||
}
|
||||
}()
|
||||
@ -48,6 +55,8 @@ func NewACMESolverCommand(stopCh <-chan struct{}) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
<-completedCh
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user