Fix hanging during shutdown and logstash output #1
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.
I don't know go, so this is most likely not a great fix, but it fixes the issues I was having.
My test system is running Ubuntu 14.04 LTS, if that matters.
Symptom 1.
execbeat_console.yml
/usr/bin/execbeat -e -c execbeat_console.yml -d "publish"
Pressing ctrl+c gives:
Symptom 2.
Sometimes pressing ctrl+c does not close the process. It must be killed with
sudo kill -9 [pid]
Symptom 3.
logstash.conf
execbeat_logstash.yml
execbeat hangs after the third publish. In this case it must always be killed with kill -9.
Explanation
I believe the infinite busy loop
for { }
in execbeat.go was only used to keep the main thread from exiting whileExecutor
does its thing. I also believe it's the main culprit of the problems.I examined topbeat and saw that it used a
Ticker
to schedule events and as a side effect, to keep the main thread running while waiting until it's time to trigger the next event.For execbeat, we don't need to use
Ticker
to schedule events since that's handled byExecutor
, so with my fix we're merely usingTicker
's side effect of keeping the main thread running. This seems like a bit of a hack to me, but with no experience in go, I'm not sure what the recommended strategy is.With my code changes in place, my manual testing shows that ctrl+c cleanly shuts down the program, and using logstash as an output no longer hangs after just a few publishes.