mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Run task shutdown_delay regardless of service registration
task shutdown_delay will currently only run if there are registered services for the task. This implementation detail isn't explicity stated anywhere and is defined outside of the service stanza. This change moves shutdown_delay to be evaluated after prekill hooks are run, outside of any task runner hooks. just use time.sleep
This commit is contained in:
@@ -844,6 +844,14 @@ func (tr *TaskRunner) handleKill() *drivers.ExitResult {
|
||||
// Run the pre killing hooks
|
||||
tr.preKill()
|
||||
|
||||
// Wait for task ShutdownDelay after running prekill hooks
|
||||
// This allows for things like service de-registration to run
|
||||
// before waiting to kill task
|
||||
if delay := tr.Task().ShutdownDelay; delay != 0 {
|
||||
tr.logger.Debug("waiting before killing task", "shutdown_delay", delay)
|
||||
time.Sleep(delay)
|
||||
}
|
||||
|
||||
// Tell the restart tracker that the task has been killed so it doesn't
|
||||
// attempt to restart it.
|
||||
tr.restartTracker.SetKilled()
|
||||
|
||||
Reference in New Issue
Block a user