-
Notifications
You must be signed in to change notification settings - Fork 249
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
fix: Ensure HTTP server startup errors are logged (#694) #700
base: main
Are you sure you want to change the base?
Conversation
This commit modifies the goroutine that starts the HTTP server to explicitly log any errors encountered during startup, except for `http.ErrServerClosed`, which is expected during graceful shutdown. This change ensures that issues related to the server's startup, such as the address already being in use, are logged, making it easier to diagnose and fix. Closes grafana#694
Mohamad Rashad seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
As this is my first contribution, I welcome all your feedback and advice. |
@@ -44,7 +44,11 @@ func main() { | |||
}() | |||
log.Printf("HTTP server on %s", listenAddress) | |||
|
|||
go func() { log.Fatal(server.ListenAndServe()) }() | |||
go func() { |
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 think you made changes in the wrong place. This main.go
's purpose is to run integration tests.
Robert already pointed at possibility of logging out the error before return it here. Could use something like level.Error(s.log).Log("failed to start HTTP service", "msg", err.Error()
alloy/internal/service/http/http.go
Line 154 in c6f4f30
return fmt.Errorf("failed to listen on %s: %w", s.opts.HTTPListenAddr, err) |
hi @mrashad10, are you still working on this PR? If anything's troubling you, feel free to raise it here! |
Hi @hainenber Sorry but I was busy last 2 weeks, I'm not sure that I will have time to work on it this week too. |
This PR has not had any activity in the past 30 days, so the |
Bugfixes
PR Description
This commit modifies the go routine that starts the HTTP server to explicitly log any errors encountered during startup, except for
http.ErrServerClosed
, which is expected during graceful shutdown. This change ensures that issues related to the server's startup, such as the address already being in use, are logged, making it easier to diagnose and fix.Which issue(s) this PR fixes
Fixes #694
Notes to the Reviewer
PR Checklist