-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat(cmd) clean dangling unix sockets on startup #9254
Conversation
Any reason we do not turn this feature on by default? |
The primary risk I can think of is that if the master pid file is lost at runtime, That's all edge case territory, but losing a pid file to logrotate or somebody's errant filesystem cleanup cron is definitely not unheard of. Docker/systemd will run with daemon=off, so losing track of the nginx master pid is not really much of a worry there. |
@flrgh Hmm, I have been thinking about it, if the master PID file is lost, Nginx will fail to |
Weirdly enough, there's nothing to prevent us from overwriting Lines 24 to 27 in d6307f2
|
@flrgh Discussed with the team, let's enable this by default and make it into 3.0 as a feature (with a bit more elaborate warning when dangling sockets are detected and removed). |
No |
If Kong is already running, `kong start` should not "prepare" or otherwise alter the prefix directory.
7ed31b8
to
5da2a09
Compare
@dndx okay, this is ready for review now. I have also added a fix for the problem I mentioned here and added a test case for it. We should not be altering the prefix directory in |
Cherry-picked from #13079 Co-authored-by: Chrono <[email protected]>
Summary
This change set makes Kong more likely to recover from an unclean shutdown.
It also includes a bugfix for
kong start
wherein the.kong_env
file could be rewritten (among other things) if Kong is already running.Background
When Nginx suffers an unclean shutdown (HW issue, OS issue,
SIGKILL
, etc), it may fail to clean up any listening unix sockets from the filesystem. The presence of these will cause Kong to fail to start back up again:Solution
Kong will search for any existing unix sockets within the prefix directory and remove them before attempting to start nginx. If Kong/nginx is already running, no action is taken.
Limits
The search for dangling sockets is performed only in the top-level prefix directory (no recursion), so this will become less effective if at some point we add a unix socket in a nested directory. The integration tests I've added would likely catch this condition, unless said socket is not created by default.