projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into 9397-prepopulate-output-directory
[arvados.git]
/
services
/
crunch-dispatch-local
/
crunch-dispatch-local.go
diff --git
a/services/crunch-dispatch-local/crunch-dispatch-local.go
b/services/crunch-dispatch-local/crunch-dispatch-local.go
index 936a9088ed0c3d3affe6c3e0f9555d9e230d0c99..bb3c05c7eb88b9abed4ff8278ff3fbdfcf367be8 100644
(file)
--- a/
services/crunch-dispatch-local/crunch-dispatch-local.go
+++ b/
services/crunch-dispatch-local/crunch-dispatch-local.go
@@
-10,7
+10,9
@@
import (
"log"
"os"
"os/exec"
"log"
"os"
"os/exec"
+ "os/signal"
"sync"
"sync"
+ "syscall"
"time"
)
"time"
)
@@
-54,16
+56,24
@@
func doMain() error {
arv.Retries = 25
dispatcher := dispatch.Dispatcher{
arv.Retries = 25
dispatcher := dispatch.Dispatcher{
- Arv:
arv,
- RunContainer:
run,
- Poll
Interval
: time.Duration(*pollInterval) * time.Second,
-
DoneProcessing: make(chan struct{})
}
+ Arv: arv,
+ RunContainer: run,
+ Poll
Period
: time.Duration(*pollInterval) * time.Second,
+ }
- err = dispatcher.Run
Dispatcher
()
+ err = dispatcher.Run()
if err != nil {
return err
}
if err != nil {
return err
}
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
+ sig := <-c
+ log.Printf("Received %s, shutting down", sig)
+ signal.Stop(c)
+
+ dispatcher.Stop()
+
runningCmdsMutex.Lock()
// Finished dispatching; interrupt any crunch jobs that are still running
for _, cmd := range runningCmds {
runningCmdsMutex.Lock()
// Finished dispatching; interrupt any crunch jobs that are still running
for _, cmd := range runningCmds {
@@
-168,7
+178,7
@@
func run(dispatcher *dispatch.Dispatcher,
}
// drain any subsequent status changes
}
// drain any subsequent status changes
- for
_ =
range status {
+ for range status {
}
log.Printf("Finalized container %v", uuid)
}
log.Printf("Finalized container %v", uuid)