It seems like nothing in nomad really calls this code - but since I'm no golang hero in any respect, I figured it's better to ask than to axe:
|
// shutdown shuts down the container, with `timeout` grace period |
|
// before killing the container with SIGKILL. |
|
func (h *taskHandle) shutdown(timeout time.Duration) error { |
|
// Wait for the process to finish or kill it after a timeout (whichever happens first): |
|
var fixTimeOut time.Duration |
|
fixTimeOut = 5 * time.Second |
|
|
|
h.procState = drivers.TaskStateExited |
|
done := make(chan error, 1) |
|
go func() { |
|
done <- h.syexec.cmd.Wait() |
|
}() |
|
select { |
|
case <-time.After(fixTimeOut * time.Second): |
|
|
|
if err := h.syexec.cmd.Process.Kill(); err != nil { |
|
return fmt.Errorf("failed to kill process: %v ", err) |
|
} |
|
case err := <-done: |
|
if err != nil { |
|
return fmt.Errorf("process finished with error = %v", err) |
|
} |
|
} |
|
|
|
return nil |
|
} |
It seems like nothing in nomad really calls this code - but since I'm no golang hero in any respect, I figured it's better to ask than to axe:
nomad-pot-driver/driver/handle.go
Lines 76 to 101 in 1fa712f