In containerized workloads, it's common to receive a SIGTERM signal when a pod or task is shutting down. Currently, when this occurs, the rake task throws a SignalException and returns a status code of 1. This behavior can be misinterpreted by container orchestration systems (like Fargate, Kubernetes, etc.) as an error, rather than a graceful exit.
This PR proposes that, when a SIGTERM signal is received by a rake task, it should return an exit code of 143. This exit code is the standard response for a SIGTERM, indicating a proper shutdown was acknowledged and handled gracefully.
I only added this for SIGTERM, but should be extensive for other handlers too if needed in future.
In containerized workloads, it's common to receive a
SIGTERM
signal when a pod or task is shutting down. Currently, when this occurs, therake
task throws aSignalException
and returns a status code of1
. This behavior can be misinterpreted by container orchestration systems (like Fargate, Kubernetes, etc.) as an error, rather than a graceful exit.This PR proposes that, when a
SIGTERM
signal is received by arake
task, it should return an exit code of143
. This exit code is the standard response for aSIGTERM
, indicating a proper shutdown was acknowledged and handled gracefully.I only added this for SIGTERM, but should be extensive for other handlers too if needed in future.
Related: https://github.com/ruby/rake/issues/272