-
Notifications
You must be signed in to change notification settings - Fork 21
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
vspd: Introduce vspd struct. #409
Conversation
912fa31
to
d46fe56
Compare
cmd/vspd/main.go
Outdated
// stops all started services when a shutdown is requested. | ||
func (v *vspd) run() int { | ||
|
||
v.log.Criticalf("Version %s (Go version %s %s/%s)", version.String(), runtime.Version(), |
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.
Critical is supposed to be for fatal failures. Most libs even do full on aborts os.Exit
style on critical. For example, see how wallet only uses it with the Fatal family of funcs when implementing the stdlib interface.
I know the code was already this way, but it's not really correct.
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 wanted to ensure that startup and shutdown messages are always logged regardless of the level set in config - is there any other way to achieve this? I got the idea from another dcr* repo (I have a feeling it was dcrdex or dcrlnd) but I cant find it now.
I've only seen the "log and abort" behaviour on Fatal, never on Critical. Both the stdlib logger and the testing package do this. I had interpreted the difference as "this error is fatal and cannot be recovered" vs "this message is critical and must be logged".
One could also argue that considering the point of view of a sysadmin or a monitoring solution, the application completely shutting down really is a more important thing to be aware of than it encountering a recoverable error.
Storing all of the essential resources such as db, rpcs and logger in a vspd struct enables vspd functions to be called without passing a bunch of parameters unnecessarily. This will be increasingly useful later when further changes are introduced.
Moving all vspd code into its own vspd.go file (fka background.go). This leaves main.go as a minimal entry point for the vspd executable.
Storing all of the essential resources such as db, rpcs and logger in a vspd struct enables vspd functions to be called without passing a bunch of parameters unnecessarily. This will be increasingly useful later when further changes are introduced.
Requires #408 and #410