Add explicit SIGTERM and SIGINT handlers.#1106
Merged
eakraly merged 2 commits intocoturn:masterfrom Dec 7, 2022
Merged
Conversation
This is required in order for these signals to be received properly when coturn is running as pid 1 inside a container, as signal handling for pid 1 (in any pid namespace) is special.
eea1d66 to
d565690
Compare
eakraly
reviewed
Dec 4, 2022
src/apps/relay/mainrelay.c
Outdated
| } | ||
|
|
||
| static void shutdown_handler(evutil_socket_t sock, short events, void *args) { | ||
| TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Caught signal, terminating\n"); |
Collaborator
There was a problem hiding this comment.
We cannot know what signal was sent
Should we have different handlers (per signal) instead?
Will look like code duplication but eventually will give us opportunity to handle different signals in different way (not to mention proper logging)
Contributor
Author
There was a problem hiding this comment.
Does cdec597 fix this issue? I took a quick look at the libevent documentation, and it seems that for signal handlers, the signal number is provided to the callback in the evutil_socket_t argument, so this value can be included in the log message.
eakraly
approved these changes
Dec 7, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
coturn running inside a docker container runs as PID 1, however PID 1 has special signal handling semantics (see the note at the bottom of the section here). coturn relies on the default behaviour of SIGTERM to terminate the process, however as no signal handler is explicitly installed, it doesn't respond to SIGTERM when running inside a container. This PR fixes this problem by installing explicit signal handlers for SIGINT and SIGTERM, which trigger the same termination mechanism as the admin interface "halt" command.
This is a port of wireapp#6 for upstream.