diff --git a/bin/start-nginx b/bin/start-nginx index dbf19062..cce0f7cd 100755 --- a/bin/start-nginx +++ b/bin/start-nginx @@ -1,5 +1,7 @@ #!/usr/bin/env bash +trap "echo start-nginx got SIGTERM. Ignoring while nginx shuts down gracefully" SIGTERM + psmgr=/tmp/nginx-buildpack-wait rm -f $psmgr mkfifo $psmgr diff --git a/bin/start-nginx-debug b/bin/start-nginx-debug index 8a6b0912..e9af51fe 100755 --- a/bin/start-nginx-debug +++ b/bin/start-nginx-debug @@ -1,5 +1,7 @@ #!/usr/bin/env bash +trap "echo start-nginx-debug got SIGTERM. Ignoring while nginx shuts down gracefully" SIGTERM + psmgr=/tmp/nginx-buildpack-wait rm -f $psmgr mkfifo $psmgr diff --git a/bin/start-nginx-solo b/bin/start-nginx-solo index f8eccd99..b45d25cb 100755 --- a/bin/start-nginx-solo +++ b/bin/start-nginx-solo @@ -1,5 +1,7 @@ #!/usr/bin/env bash +trap "echo start-nginx-solo got SIGTERM. Ignoring while nginx shuts down gracefully" SIGTERM + psmgr=/tmp/nginx-buildpack-wait rm -f $psmgr mkfifo $psmgr diff --git a/changelog.md b/changelog.md index 7f20f21a..356468e8 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [x.x] - xxxx-xx-xx +### Changes +- [all] Patched nginx so it gracefully shuts down on SIGTERM. +- [all] start-nginx scripts ignore the SIGTERM signal so they do not kill off nginx abruptly. + ## [1.7] - 2021-06-04 ### Changes - [heroku-18] updated nginx to 1.20.1 diff --git a/nginx-heroku-18.tgz b/nginx-heroku-18.tgz index a9e5e6a4..81f51e73 100644 Binary files a/nginx-heroku-18.tgz and b/nginx-heroku-18.tgz differ diff --git a/nginx-heroku-20.tgz b/nginx-heroku-20.tgz index 85d4a6e8..2bc0534f 100644 Binary files a/nginx-heroku-20.tgz and b/nginx-heroku-20.tgz differ diff --git a/scripts/build_nginx b/scripts/build_nginx index 68546838..86874c4c 100755 --- a/scripts/build_nginx +++ b/scripts/build_nginx @@ -36,6 +36,23 @@ echo "Downloading $zlib_url" echo "Downloading $uuid4_url" (cd nginx-${NGINX_VERSION} && curl -L $uuid4_url | tar xvz ) +if [ -d "/buildpack/scripts/patchfiles/${NGINX_VERSION}" ] +then + PATCHFILES=$(find /buildpack/scripts/patchfiles/${NGINX_VERSION} -name '*.patch') +else + PATCHFILES=$(find /buildpack/scripts/patchfiles/default -name '*.patch') +fi + + +( + cd nginx-${NGINX_VERSION} + for f in $PATCHFILES + do + echo "patch: $f" + patch -p0 < $f + done +) + # This will build `nginx` ( cd nginx-${NGINX_VERSION} diff --git a/scripts/patchfiles/default/0001-Custom-Terminate-Signal.patch b/scripts/patchfiles/default/0001-Custom-Terminate-Signal.patch new file mode 100644 index 00000000..0593a91f --- /dev/null +++ b/scripts/patchfiles/default/0001-Custom-Terminate-Signal.patch @@ -0,0 +1,13 @@ +--- src/core/ngx_config.h 2020-05-23 04:21:07.000000000 +0000 ++++ src/core/ngx_config.h 2020-05-23 04:15:17.000000000 +0000 +@@ -56,9 +56,8 @@ + + #define ngx_random random + +-/* TODO: #ifndef */ +-#define NGX_SHUTDOWN_SIGNAL QUIT +-#define NGX_TERMINATE_SIGNAL TERM ++#define NGX_SHUTDOWN_SIGNAL TERM ++#define NGX_TERMINATE_SIGNAL QUIT + #define NGX_NOACCEPT_SIGNAL WINCH + #define NGX_RECONFIGURE_SIGNAL HUP \ No newline at end of file