Make HTTP server wait for tasks before shutdown #1390
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1335
Description of the Change
This code change prevents SIGINT/SIGTERM signals from stopping the Aptly API server before it has cleaned up any resource locks in the database. Normally for CLI aptly commands, it would clear these locks if it detects the PID that had the previous lock is no longer running. However, if Aptly is running as an API server in a container, it always runs as PID 1, which means the PID no longer works as a unique identifier to detect what is running at any given time, leaving these locks indefinitely.
Even with this MR, this issue can still present itself if an Aptly container is SIGKILLed (docker rm -f), however that is a more difficult problem to solve that would likely take some significant rearchitecting (since the API was tacked on to aptly after the fact).
Checklist