mirror of
https://gitea.com/gitea/act_runner.git
synced 2025-12-19 20:44:58 +00:00
feat: allow graceful shutdowns
Add a Shutdown(context.Context) method to the Poller. This will first shutdown all active polling, preventing any new jobs from spawning. It will then wait for either all jobs to finish, or for the context to finish. If the context finishes, it will then force all jobs to end, and then exit.
This commit is contained in:
@@ -122,9 +122,12 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
|
||||
|
||||
poller := poll.New(cfg, cli, runner)
|
||||
|
||||
poller.Poll(ctx)
|
||||
go poller.Poll()
|
||||
|
||||
return nil
|
||||
<-ctx.Done()
|
||||
log.Infof("runner: %s gracefully shutting down", resp.Msg.Runner.Name)
|
||||
|
||||
return poller.Shutdown(context.Background())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user