Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graceful shutdowns #31

Closed
biw opened this issue Mar 3, 2019 · 6 comments · May be fixed by #88
Closed

graceful shutdowns #31

biw opened this issue Mar 3, 2019 · 6 comments · May be fixed by #88

Comments

@biw
Copy link

biw commented Mar 3, 2019

Hello 👋, I'm having a little trouble making sure that my server restarts gracefully. I have my script waiting for SIGTERM but it doesn't seem like they get called, is there a way I can watch for them and pass them to my (node) app? 😄

@garhiggins
Copy link

I've been struggling with this also. We forked the start script and trapped the SIGTERM and then send the nginx -s QUIT, but it doesn't seem to help. I believe the problem is that Heroku sends a SIGTERM to all processes (https://devcenter.heroku.com/articles/dynos#shutdown), not just the bash script, so nginx still sees a SIGTERM and does a fast shutdown. We drop a ton of requests every time we deploy :(

@sidonath
Copy link

Ouch!

I looked into the source and there's a TODO: #ifndef next to

#define NGX_SHUTDOWN_SIGNAL      QUIT
#define NGX_TERMINATE_SIGNAL     TERM

If we could land a change in Nginx to wrap those two within #ifndef indeed, we could compile a Heroku-friendlier version of Nginx that treats SIGTERM as SIGQUIT. Not sure if that's a good idea, but it would help with this issue.

@mguida22
Copy link

👀 Any updates on this?

@beanieboi
Copy link
Member

@mguida22 this is outside of the scope of this buildpack. it has to do with the Heroku platform itself and how nginx works. there is nothing this buildpack can do.

@mguida22
Copy link

@beanieboi thanks for the reply!

Is there a better place to bring up this issue with the Heroku platform?

@beanieboi
Copy link
Member

@mguida22 This is a known issue and since this i a behavior of the platform for a long time, i believe there is no way to fix it without breaking a lot of applications. I think our only chance is to patch nginx to react differently. We do this in the pgbouncer buildpack and it works ok.
https://github.com/heroku/heroku-buildpack-pgbouncer/blob/master/support/patchfiles/1.13.0/0001-Disable-SIGTERM.patch

syastrov added a commit to Boligportal/heroku-buildpack-nginx that referenced this issue Aug 6, 2021
syastrov added a commit to Boligportal/heroku-buildpack-nginx that referenced this issue Aug 6, 2021
@biw biw closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants