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"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus"
|
||||
"github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient"
|
||||
|
@ -56,6 +58,16 @@ func main() {
|
|||
ctx.client = client
|
||||
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
|
||||
// prior to executing our build tasks.
|
||||
createClone(ctx)
|
||||
|
|
Loading…
Reference in a new issue