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

Friendlier Startup Error Messages #1894

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func main() {

cfg, err := loadConfig()
if err != nil {
glog.Fatalf("Configuration could not be loaded or did not pass validation: %v", err)
glog.Exitf("Configuration could not be loaded or did not pass validation: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand switching Errorf to Exitf in line 42 but I don't quite understand the reason behind the change from Fatalf to Exitf in line 37. The error code "255" usually means that it is not able to find a file the system needs to execute. Isn't it more descriptive to use Fatalf instead of Exitf in line 37?

1144 // Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs,
1145 // including a stack trace of all running goroutines, then calls os.Exit(255).
1146 // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
1147 func Fatalf(format string, args ...interface{}) {
1148     logging.printf(fatalLog, format, args...)
1149 }
1150 +-- 24 lines: fatalNoStacks is non-zero if we are to exit without dumping goroutine stacks.--
1174
1175 // Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
1176 // Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
1177 func Exitf(format string, args ...interface{}) {
1178     atomic.StoreUint32(&fatalNoStacks, 1)
1179     logging.printf(fatalLog, format, args...)
1180 }
~/go/pkg/mod/github.com/golang/glog@v0.0.0-20160126235308-23def4e6c14b/glog.go [RO]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exitf will return exit code 1, or general error. I can't find a definition of 255 to mean file not found. Where did you see that correlation?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right. I got it wrong, according to this bash shell doc it is regarded as Exit status out of range. An exit status of 1, should do.

}

err = serve(Rev, cfg)
if err != nil {
glog.Errorf("prebid-server failed: %v", err)
glog.Exitf("prebid-server failed: %v", err)
}
}

Expand Down