mirror of
				https://gitea.com/gitea/act_runner.git
				synced 2025-10-31 12:57:56 +01:00 
			
		
		
		
	feat: allow graceful shutdowns (#546)
Add a `Shutdown(context.Context) error` method to the Poller. Calling this method 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 be cancelled. If the context is cancelled, it will then force all jobs to end, and then exit. Fixes https://gitea.com/gitea/act_runner/issues/107 Co-authored-by: Rowan Bohde <rowan.bohde@gmail.com> Reviewed-on: https://gitea.com/gitea/act_runner/pulls/546 Reviewed-by: Jason Song <i@wolfogre.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: rowan-allspice <rowan-allspice@noreply.gitea.com> Co-committed-by: rowan-allspice <rowan-allspice@noreply.gitea.com>
This commit is contained in:
		
				
					committed by
					
						 Lunny Xiao
						Lunny Xiao
					
				
			
			
				
	
			
			
			
						parent
						
							1735b26e66
						
					
				
				
					commit
					d1d3cad4b0
				
			| @@ -21,15 +21,16 @@ type Log struct { | ||||
|  | ||||
| // Runner represents the configuration for the runner. | ||||
| type Runner struct { | ||||
| 	File          string            `yaml:"file"`           // File specifies the file path for the runner. | ||||
| 	Capacity      int               `yaml:"capacity"`       // Capacity specifies the capacity of the runner. | ||||
| 	Envs          map[string]string `yaml:"envs"`           // Envs stores environment variables for the runner. | ||||
| 	EnvFile       string            `yaml:"env_file"`       // EnvFile specifies the path to the file containing environment variables for the runner. | ||||
| 	Timeout       time.Duration     `yaml:"timeout"`        // Timeout specifies the duration for runner timeout. | ||||
| 	Insecure      bool              `yaml:"insecure"`       // Insecure indicates whether the runner operates in an insecure mode. | ||||
| 	FetchTimeout  time.Duration     `yaml:"fetch_timeout"`  // FetchTimeout specifies the timeout duration for fetching resources. | ||||
| 	FetchInterval time.Duration     `yaml:"fetch_interval"` // FetchInterval specifies the interval duration for fetching resources. | ||||
| 	Labels        []string          `yaml:"labels"`         // Labels specify the labels of the runner. Labels are declared on each startup | ||||
| 	File            string            `yaml:"file"`             // File specifies the file path for the runner. | ||||
| 	Capacity        int               `yaml:"capacity"`         // Capacity specifies the capacity of the runner. | ||||
| 	Envs            map[string]string `yaml:"envs"`             // Envs stores environment variables for the runner. | ||||
| 	EnvFile         string            `yaml:"env_file"`         // EnvFile specifies the path to the file containing environment variables for the runner. | ||||
| 	Timeout         time.Duration     `yaml:"timeout"`          // Timeout specifies the duration for runner timeout. | ||||
| 	ShutdownTimeout time.Duration     `yaml:"shutdown_timeout"` // ShutdownTimeout specifies the duration to wait for running jobs to complete during a shutdown of the runner. | ||||
| 	Insecure        bool              `yaml:"insecure"`         // Insecure indicates whether the runner operates in an insecure mode. | ||||
| 	FetchTimeout    time.Duration     `yaml:"fetch_timeout"`    // FetchTimeout specifies the timeout duration for fetching resources. | ||||
| 	FetchInterval   time.Duration     `yaml:"fetch_interval"`   // FetchInterval specifies the interval duration for fetching resources. | ||||
| 	Labels          []string          `yaml:"labels"`           // Labels specify the labels of the runner. Labels are declared on each startup | ||||
| } | ||||
|  | ||||
| // Cache represents the configuration for caching. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user