Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle graceful reload #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

aldy505
Copy link
Contributor

@aldy505 aldy505 commented Aug 12, 2023

  • replace logrus with zerolog, do more detailed logging
  • remove fatal exit on not found sentry dsn, to enable debugging
  • create e2e log application sample for debugging I removed this one
  • use cond to broadcast and gracefully exit every running process to flush and close file descriptors

aldy505 and others added 6 commits April 25, 2023 11:35
* replace logrus with zerolog, do more detailed logging

* remove fatal exit on not found sentry dsn, to enable debugging

* create e2e log application sample for debugging

* use cond to broadcast and gracefully exit every running process to flush and close file descriptors
Comment on lines +133 to +134
// Initiate logging
initLogging()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to move logging below parsing the command argument, because I need the _verbose variable to be set first. In order to know what kind of logging level should the program use.

@@ -78,12 +58,12 @@ func parseTimestamp(str string) int64 {
return fallback
}

time, err := dateparse.ParseLocal(str)
localTime, err := dateparse.ParseLocal(str)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was getting a warning on my IDE (IntelliJ), that says variable named "time" might be troublesome if we're about to import Go's stdlib time package.

process.go Outdated
Comment on lines 150 to 157
defer func() {
log.Debug().Str("path", absFilePath).Msg("Closing file")

err := file.Close()
if err != nil {
log.Error().Err(err).Str("path", absFilePath).Msg("Closing file")
}
}()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that we never close the file. Now it should not be a problem anymore.

process.go Outdated
Comment on lines 230 to 232
// Gracefully handles Sentry flush and close file descriptors.
log.Debug().Msgf("Finished reading from %q, flushing events...", absFilePath)
hub.Flush(10 * time.Second)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an unreachable code before.

main.go Outdated
Comment on lines 202 to 203
// NOTE: should this be configurable in the future?
time.Sleep(time.Second * 10)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really need feedback about this. I actually wanted to use SIGUSR1 and SIGUSR2. But realizing that it's not available on Windows (and I'm developing this on Windows too), I chose SIGHUP instead.

If I were to use SIGUSR1 and SIGUSR2, we might use SIGUSR1 to stop sentlog and SIGUSR2 to start it again. But considering this, people might use Windows and tail their Windows application logs or something.

I think this really needs to be configured, with default time of 10 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant