mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-04-26 21:44:44 +00:00
trap SIGINT and cleanup containers
This commit is contained in:
parent
f5721a9383
commit
50d3ea8e00
1 changed files with 12 additions and 0 deletions
|
@ -6,7 +6,9 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
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"
|
||||||
|
@ -56,6 +58,16 @@ func main() {
|
||||||
ctx.client = client
|
ctx.client = client
|
||||||
defer client.Destroy()
|
defer client.Destroy()
|
||||||
|
|
||||||
|
// watch for sigkill (timeout or cancel build)
|
||||||
|
killc := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(killc, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
go func() {
|
||||||
|
<-killc
|
||||||
|
log.Println("Received reques to kill this build")
|
||||||
|
client.Destroy() // possibe race here. implement lock on the other end
|
||||||
|
os.Exit(1)
|
||||||
|
}()
|
||||||
|
|
||||||
// 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)
|
||||||
|
|
Loading…
Reference in a new issue