build runner now in charge of timeout

This commit is contained in:
Brad Rydzewski 2015-08-21 15:30:32 -07:00
parent bf1b9d2d8a
commit b264e837fe
2 changed files with 12 additions and 4 deletions

View file

@ -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

View file

@ -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
}
}