-
Notifications
You must be signed in to change notification settings - Fork 6
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
Refactor of main to allow graceful shutdown #158
Conversation
Since we forked geth, is there any existing code to reuse or reference. |
@@ -45,6 +47,14 @@ type Config struct { | |||
Networks []string | |||
} | |||
|
|||
type Client struct { | |||
DiscV5API *discover.DiscV5API |
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.
DiscV5API
is not needed to close. In fact, all network use the same UDPv5
, every network will stop the discv5 when call the Stop method
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.
Since DiscV5
not managed by sub networks, I would like to suggest we don't close discV5 in sub networks close function and close by the outside management object.
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 tried to move the closure of DiskV5
from PortalProtocol
, where it was originally, to main
, but it broke a test and may potentially break other parts of the code that calls PortalProtocol.Close()
.
DiscV5
close uses a sync.Once
struct and can safely be closed many times:
Line 193 in b061173
func (t *UDPv5) Close() { |
The reference comes from Line 77 in b061173
StartNode ) a goroutine watches a channel for signals of interruption and executes the shutdown function (Line 115 in b061173
I studied this file to understand how to handle a Other aspect is the behavior/functionality of CTRL-C command: in geth to force quit is necessary to press 10 times CTRL-C, or panic behavior: for i := 10; i > 0; i-- {
<-sigc
if i > 1 {
log.Warn("Already shutting down, interrupt more to panic.", "times", i-1)
}
} while in Shisui only a second press of CTRL-c quits. Please let me know if there is a better approach I should implement. |
solves #156