mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-18 13:35:43 +00:00
build runner now in charge of timeout
This commit is contained in:
parent
bf1b9d2d8a
commit
b264e837fe
2 changed files with 12 additions and 4 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus"
|
log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus"
|
||||||
"github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient"
|
"github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient"
|
||||||
|
@ -63,11 +64,18 @@ func main() {
|
||||||
signal.Notify(killc, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(killc, syscall.SIGINT, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
<-killc
|
<-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
|
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
|
// performs some initial parsing and pre-processing steps
|
||||||
// prior to executing our build tasks.
|
// prior to executing our build tasks.
|
||||||
createClone(ctx)
|
createClone(ctx)
|
||||||
|
|
|
@ -242,7 +242,7 @@ func run(client dockerclient.Client, conf *dockerclient.ContainerConfig, name st
|
||||||
return info, nil
|
return info, nil
|
||||||
case err := <-errc:
|
case err := <-errc:
|
||||||
return info, err
|
return info, err
|
||||||
case <-time.After(timeout):
|
// case <-time.After(timeout):
|
||||||
return info, ErrTimeout
|
// return info, ErrTimeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue