feat: implement build timeout

Jef Roosens 2023-05-02 14:49:32 +02:00
parent 2f163cf614
commit f4662d7cdc
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 8 additions and 0 deletions

View File

@ -136,9 +136,17 @@ pub fn build_config(address string, api_key string, config BuildConfig) !BuildRe
dd.container_start(id)! dd.container_start(id)!
mut data := dd.container_inspect(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 // This loop waits until the container has stopped, so we can remove it after
for data.state.running { 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) time.sleep(1 * time.second)
data = dd.container_inspect(id)! data = dd.container_inspect(id)!