Skip to content

Commit

Permalink
Merge pull request #26 from bryanlatten/feature-signals
Browse files Browse the repository at this point in the history
Nginx: use SIGQUIT instead of SIGTERM for graceful shutdown
  • Loading branch information
Bryan Latten committed Mar 31, 2016
2 parents efeae27 + 560962c commit 668578d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions container/root/etc/services-available/nginx/finish
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#!/usr/bin/execlineb -S1

# @see https://github.com/just-containers/s6-overlay/issues/101

# Rely on container platform to restart this container on crash (marathon/docker-swarm/kubernetes)
# BUT, when container is SIGNALLED to stop, don't interfere
if { s6-test ${1} -ne 0 }
if { s6-test ${1} -ne 256 }

# When nginx process dies, the container should come down with it
s6-svscanctl -t /var/run/s6/services
18 changes: 16 additions & 2 deletions container/root/etc/services-available/nginx/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/usr/bin/execlineb -P
s6-setuidgid www-data

nginx -g "daemon off;"
# @see https://github.com/just-containers/s6-overlay/issues/41#issuecomment-99366363

# Nginx uses SIGQUIT to gracefully stop serving traffic.
trap -x
{
term
{
foreground
{
nginx -s quit
}
echo [sigterm-nginx] graceful shutdown complete
}
}

s6-setuidgid www-data nginx -g "daemon off;"

0 comments on commit 668578d

Please sign in to comment.