Set a time limit on runners
This commit is contained in:
		
							parent
							
								
									d632111c45
								
							
						
					
					
						commit
						0db2ff3409
					
				
							
								
								
									
										16
									
								
								acid.go
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								acid.go
									
									
									
									
									
								
							| @ -81,8 +81,9 @@ type ConfigProject struct { | ||||
| } | ||||
| 
 | ||||
| type ConfigProjectRunner struct { | ||||
| 	Setup string `yaml:"setup"` // project setup script (SSH) | ||||
| 	Build string `yaml:"build"` // project build script (SSH) | ||||
| 	Setup   string `yaml:"setup"`   // project setup script (SSH) | ||||
| 	Build   string `yaml:"build"`   // project build script (SSH) | ||||
| 	Timeout string `yaml:"timeout"` // timeout duration | ||||
| } | ||||
| 
 | ||||
| func parseConfig(path string) error { | ||||
| @ -937,6 +938,17 @@ func executorRunTask(ctx context.Context, task Task) error { | ||||
| 		return fmt.Errorf("script: %w", err) | ||||
| 	} | ||||
| 
 | ||||
| 	// Lenient or not, some kind of a time limit is desirable. | ||||
| 	timeout := time.Hour | ||||
| 	if rt.ProjectRunner.Timeout != "" { | ||||
| 		timeout, err = time.ParseDuration(rt.ProjectRunner.Timeout) | ||||
| 		if err != nil { | ||||
| 			return fmt.Errorf("timeout: %w", err) | ||||
| 		} | ||||
| 	} | ||||
| 	ctx, cancelTimeout := context.WithTimeout(ctx, timeout) | ||||
| 	defer cancelTimeout() | ||||
| 
 | ||||
| 	privateKey, err := os.ReadFile(rt.Runner.SSH.Identity) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf( | ||||
|  | ||||
| @ -62,3 +62,7 @@ projects: | ||||
|         build: | | ||||
|           echo Computing line count... | ||||
|           find . -not -path '*/.*' -type f -print0 | xargs -0 cat | wc -l | ||||
| 
 | ||||
|         # Time limit in time.ParseDuration format. | ||||
|         # The default of one hour should suffice. | ||||
|         timeout: 1h | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user