SIGTERM — a request to terminate (graceful). SIGKILL — forced termination (cannot be intercepted). On deploy, SIGTERM is usually sent, waited on for N seconds (timeout), then SIGKILL.
pcntl_signal(SIGTERM, function () {
$this->shouldStop = true; // stop worker loop after current task
});
pcntl_async_signals(true);
terminationGracePeriodSeconds — the wait time between SIGTERM and SIGKILL. Default: 30 seconds.