From b264e837fe31aa794d83f822c29c139421a90937 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 21 Aug 2015 15:30:32 -0700 Subject: [PATCH] build runner now in charge of timeout --- cmd/drone-build/main.go | 12 ++++++++++-- pkg/runner/builtin/worker.go | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/drone-build/main.go b/cmd/drone-build/main.go index 6e8822d1..25050de1 100644 --- a/cmd/drone-build/main.go +++ b/cmd/drone-build/main.go @@ -9,6 +9,7 @@ import ( "os/signal" "strings" "syscall" + "time" log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus" "github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient" @@ -63,9 +64,16 @@ func main() { signal.Notify(killc, syscall.SIGINT, syscall.SIGTERM) go func() { <-killc - log.Println("Received reques to kill this build") + log.Println("Cancel request received, killing process") client.Destroy() // possibe race here. implement lock on the other end - os.Exit(130) // cancel is treated like ctrl+c + os.Exit(130) // cancel is treated like ctrl+c + }() + + go func() { + <-time.After(time.Duration(ctx.Repo.Timeout) * time.Minute) + log.Println("Timeout request received, killing process") + client.Destroy() // possibe race here. implement lock on the other end + os.Exit(128) // cancel is treated like ctrl+c }() // performs some initial parsing and pre-processing steps diff --git a/pkg/runner/builtin/worker.go b/pkg/runner/builtin/worker.go index cc454b97..ddb3b199 100644 --- a/pkg/runner/builtin/worker.go +++ b/pkg/runner/builtin/worker.go @@ -242,7 +242,7 @@ func run(client dockerclient.Client, conf *dockerclient.ContainerConfig, name st return info, nil case err := <-errc: return info, err - case <-time.After(timeout): - return info, ErrTimeout + // case <-time.After(timeout): + // return info, ErrTimeout } }