You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SIGHUP is sent to a process if the user's terminal is disconnected. It is one of the five termination signals. Currently, Beats is going to terminate suddenly, i.e. the log will cut off, no shutdown actions are going to be run, etc.
As we handle more and more state (e.g. writing state to beat.db files) it becomes more important to gracefully shutdown in "less than ideal" situations. Beats should probably not be run directly from a terminal or a terminal multiplexer, but it probably happens, and if so the consequences of a network disconnect or clumsy fingers (I forget the number of times I've hit the wrong key when using shortcuts in tmux/screen) should not be severe if we can help it.
This change catches SIGHUP as it already does SIGINT/SIGTERM and runs the usual shutdown actions. This can include waiting for a period of time specified using the shutdown_timeout option Filebeat and Packetbeat support.
I thought we might want to exit with a non-zero exit code if we receive this unexpected signal, but I don't see a good way to specifiy the exit code in Libbeat at the moment.
The reason will be displayed to describe this comment to others. Learn more.
I recommend putting some tests in place from the system tests to send in a SIGHUP. This way it gets tested on multiple OSes and we can make sure nothing unusual is happening upstream the Go runtimes signal handling (it has some builtin handlers).
Even if it was not intended for that, SIGHUP is commonly used to request a configuration reload in services/daemons in unix systems. One of the reasons to use this signal for that is that daemons are usually not run in terminals, so they are not going to receive it by this reason. I think that Beats should be included in this category.
In any case I think it is fine to merge this by now, I agree that we should handle this signal in some way.
I recommend putting some tests in place from the system tests to send in a SIGHUP. This way it gets tested on multiple OSes and we can make sure nothing unusually is happening upstream the Go runtimes signal handling (it has some builtin handlers).
Good call, I've added a system test that sends SIGHUP and checks if it shut down correctly. Let me know what you think @andrewkroh.
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
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.
SIGHUPis sent to a process if the user's terminal is disconnected. It is one of the five termination signals. Currently, Beats is going to terminate suddenly, i.e. the log will cut off, no shutdown actions are going to be run, etc.As we handle more and more state (e.g. writing state to
beat.dbfiles) it becomes more important to gracefully shutdown in "less than ideal" situations. Beats should probably not be run directly from a terminal or a terminal multiplexer, but it probably happens, and if so the consequences of a network disconnect or clumsy fingers (I forget the number of times I've hit the wrong key when using shortcuts in tmux/screen) should not be severe if we can help it.This change catches
SIGHUPas it already doesSIGINT/SIGTERMand runs the usual shutdown actions. This can include waiting for a period of time specified using theshutdown_timeoutoption Filebeat and Packetbeat support.I thought we might want to exit with a non-zero exit code if we receive this unexpected signal, but I don't see a good way to specifiy the exit code in Libbeat at the moment.