From afb38256ac7ab48900582b13becefcc2df99d79d Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Tue, 2 May 2023 14:49:32 +0200 Subject: [PATCH] feat: implement build timeout --- src/build/build.v | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/build/build.v b/src/build/build.v index 756e8f6..b864792 100644 --- a/src/build/build.v +++ b/src/build/build.v @@ -136,9 +136,17 @@ pub fn build_config(address string, api_key string, config BuildConfig) !BuildRe dd.container_start(id)! mut data := dd.container_inspect(id)! + start_time := time.now() // This loop waits until the container has stopped, so we can remove it after for data.state.running { + if time.now() - start_time > config.timeout * time.second { + dd.container_kill(id)! + dd.container_remove(id)! + + return error('Build killed due to timeout (${config.timeout}s)') + } + time.sleep(1 * time.second) data = dd.container_inspect(id)!