mirror of
https://gitea.com/gitea/act_runner.git
synced 2025-12-19 12:34:47 +00:00
feat: add Runner.ShutdownTimeout config option
This controls the amount of time the runner will wait for running jobs to finish before cancelling them. Defaults to 0s in order to maintain backwards compatibility with previous behavior.
This commit is contained in:
@@ -125,9 +125,16 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
|
||||
go poller.Poll()
|
||||
|
||||
<-ctx.Done()
|
||||
log.Infof("runner: %s gracefully shutting down", resp.Msg.Runner.Name)
|
||||
log.Infof("runner: %s shutdown initiated, waiting %s for running jobs to complete before shutting down", resp.Msg.Runner.Name, cfg.Runner.ShutdownTimeout)
|
||||
|
||||
return poller.Shutdown(context.Background())
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cfg.Runner.ShutdownTimeout)
|
||||
defer cancel()
|
||||
|
||||
err = poller.Shutdown(ctx)
|
||||
if err != nil {
|
||||
log.Warnf("runner: %s cancelled in progress jobs during shutdown", resp.Msg.Runner.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user