Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Question: How can I ensure all asynchronous logged events are actually sent before closing process? #196

Answered by reidmorrison
jasonwbarnett asked this question in Q&A
Discussion options

I have a question about how to use this library.

How can I ensure all asynchronous logged events are actually sent before closing the process?

I'm having an issue where the process is closed by a SIGTERM and not all messages are actually sent. I'd like to create a handler that catches SIGTERM signal and calls whatever code is necessary to block until all asynchronous messages have been sent.

I'm using the :splunk_http appender.

I assume it would be a simple SemanticLogger.flush but I'd like someone to confirm my assumption.

You must be logged in to vote

Semantic Logger has a built-in flush that occurs before a process exits: https://github.com/reidmorrison/semantic_logger/blob/master/lib/semantic_logger.rb#L44

We use sigterm heavily in our AWS ECS deployment for when docker containers are being scaled down.

We had issues previously when other at_exit handlers were not finishing quickly enough after a sigterm, which caused AWS ECS to hard kill the process causing messages to be lost. Once the other at_exit handlers were fixed, we get all our log messages now.

Replies: 2 comments

Comment options

Semantic Logger has a built-in flush that occurs before a process exits: https://github.com/reidmorrison/semantic_logger/blob/master/lib/semantic_logger.rb#L44

We use sigterm heavily in our AWS ECS deployment for when docker containers are being scaled down.

We had issues previously when other at_exit handlers were not finishing quickly enough after a sigterm, which caused AWS ECS to hard kill the process causing messages to be lost. Once the other at_exit handlers were fixed, we get all our log messages now.

You must be logged in to vote
0 replies
Answer selected by reidmorrison
Comment options

I might have a similar issue of the ECS deal because my problem is happening when a server is shutting down.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Converted from issue

This discussion was converted from issue #175 on January 17, 2022 20:50.

AltStyle によって変換されたページ (->オリジナル) /