X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=blobdiff_plain;f=main.go;h=c3b1be78677b731291db45ca8af4cfab7b74a5d3;hp=67c428c14a6b6661bdc9bf94ae4dac0a0cf1062b;hb=9485b9805119a388f1d4d93d18b0fe1a2da212a0;hpb=94ace13349ab0f38aaa046d01ef1a3c00f1ea6f1 diff --git a/main.go b/main.go index 67c428c..c3b1be7 100644 --- a/main.go +++ b/main.go @@ -27,11 +27,13 @@ import ( "io/ioutil" "log" "os" + "os/signal" "path" "path/filepath" "runtime" "sort" "strconv" + "syscall" "go.cypherpunks.ru/recfile" "golang.org/x/sys/unix" @@ -282,6 +284,20 @@ func main() { } } + killed := make(chan os.Signal, 0) + signal.Notify(killed, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM) + go func() { + <-killed + trace(CDebug, "[%s] killed", BuildUUID) + jsReleaseAll() + RunningProcsM.Lock() + for pid, proc := range RunningProcs { + trace(CDebug, "[%s] killing child %d", BuildUUID, pid) + proc.Signal(syscall.SIGTERM) + } + os.Exit(1) + }() + ok := true err = nil trace(