open-nomad/website/source/docs/operating-a-job/update-strategies/handling-signals.html.md
2017-06-16 17:24:54 +02:00

1.5 KiB

layout page_title sidebar_current description
docs Handling Signals - Operating a Job docs-operating-a-job-updating-handling-signals Well-behaved applications expose a way to perform cleanup prior to exiting. Nomad can optionally send a configurable signal to applications before killing them, allowing them to drain connections or gracefully terminate.

Handling Signals

On operating systems that support signals, Nomad will send the application a configurable signal before killing it. This gives the application time to gracefully drain connections and conduct other cleanup before shutting down. Certain applications take longer to drain than others, and thus Nomad allows specifying the amount of time to wait for the application to exit before force-killing it.

Before Nomad terminates an application, it will send the SIGINT signal to the process. Processes running under Nomad should respond to this signal to gracefully drain connections. After a configurable timeout, the application will be force-terminated.

For more details on the kill_timeout option, please see the job specification documentation.

job "docs" {
  group "example" {
    task "server" {
      # ...
      kill_timeout = "45s"
    }
  }
}

Please note that the behavior is subtly different for Docker-based tasks. In this case a docker stop command is issued that will send a SIGTERM to your container entry point instead. The kill_timeout option is still respected though.