-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
* 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
// Initiate logging | ||
initLogging() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
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") | ||
} | ||
}() |
There was a problem hiding this comment.
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
// Gracefully handles Sentry flush and close file descriptors. | ||
log.Debug().Msgf("Finished reading from %q, flushing events...", absFilePath) | ||
hub.Flush(10 * time.Second) |
There was a problem hiding this comment.
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
// NOTE: should this be configurable in the future? | ||
time.Sleep(time.Second * 10) |
There was a problem hiding this comment.
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.
create e2e log application sample for debuggingI removed this one