From 0a8686b8d0298724e396edabe2a0ff64281c682c Mon Sep 17 00:00:00 2001 From: Alan Hodgson Date: Mon, 15 Jan 2024 15:14:36 -0800 Subject: [PATCH] Modifies the default signal sent to nginx when terminating the container to allow graceful exit. Solution provided by @groyoh in https://github.com/phusion/passenger-docker/issues/149#issuecomment-713467999 Closes https://github.com/phusion/passenger-docker/issues/149 --- image/nginx-passenger.sh | 4 ++++ image/runit/nginx-term | 4 ++++ 2 files changed, 8 insertions(+) create mode 100755 image/runit/nginx-term diff --git a/image/nginx-passenger.sh b/image/nginx-passenger.sh index 42fda64e..0d60e84e 100755 --- a/image/nginx-passenger.sh +++ b/image/nginx-passenger.sh @@ -48,6 +48,10 @@ run touch /etc/service/nginx/down run mkdir /etc/service/nginx-log-forwarder run cp /pd_build/runit/nginx-log-forwarder /etc/service/nginx-log-forwarder/run +## Use SIGQUIT instead of SIGTERM to shutdown nginx +run mkdir -p /etc/service/nginx/control/ +run cp /pd_build/runit/nginx-term /etc/service/nginx/control/t + run mkdir /var/run/passenger-instreg run sed -i 's|invoke-rc.d nginx rotate|sv 1 nginx|' /etc/logrotate.d/nginx diff --git a/image/runit/nginx-term b/image/runit/nginx-term new file mode 100755 index 00000000..cd590dc4 --- /dev/null +++ b/image/runit/nginx-term @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +sv q nginx