Skip to content

Commit

Permalink
Patch nginx so it does graceful shutdown on SIGTERM and fast shutdown…
Browse files Browse the repository at this point in the history
… on SIGQUIT. Fixes heroku#31
  • Loading branch information
syastrov committed Aug 6, 2021
1 parent 9be9a7c commit 91f365d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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.

## [1.7] - 2021-06-04
### Changes
- [heroku-18] updated nginx to 1.20.1
Expand Down
Binary file modified nginx-heroku-18.tgz
Binary file not shown.
Binary file modified nginx-heroku-20.tgz
Binary file not shown.
23 changes: 23 additions & 0 deletions scripts/build_nginx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@ echo "Downloading $zlib_url"
echo "Downloading $uuid4_url"
(cd nginx-${NGINX_VERSION} && curl -L $uuid4_url | tar xvz )

set -e

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}
cat src/core/ngx_config.h
for f in $PATCHFILES
do
echo "patch: $f"
patch -p0 < $f
done
cat src/core/ngx_config.h
)

set +e

# This will build `nginx`
(
cd nginx-${NGINX_VERSION}
Expand Down
13 changes: 13 additions & 0 deletions scripts/patchfiles/default/0001-Custom-Terminate-Signal.patch
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 91f365d

Please sign in to comment.