diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-04-19 04:26:48 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-04-19 04:26:48 +0200 |
commit | 0db2ff34096896a27c1f2239fecfae4f5c32b744 (patch) | |
tree | 3b086b67990fc5675164d9a9a599ee108f5fb33f /acid.go | |
parent | d632111c45683060e02fac828ad08f924e654d2d (diff) | |
download | acid-0db2ff34096896a27c1f2239fecfae4f5c32b744.tar.gz acid-0db2ff34096896a27c1f2239fecfae4f5c32b744.tar.xz acid-0db2ff34096896a27c1f2239fecfae4f5c32b744.zip |
Diffstat (limited to 'acid.go')
-rw-r--r-- | acid.go | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -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( |