-
Notifications
You must be signed in to change notification settings - Fork 469
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
Graceful shutdown #108
Graceful shutdown #108
Conversation
@@ -476,6 +486,7 @@ func (wp *wsPeer) Close() { | |||
atomic.StoreInt32(&wp.didSignalClose, 1) | |||
if atomic.CompareAndSwapInt32(&wp.didInnerClose, 0, 1) { | |||
close(wp.closing) | |||
wp.conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""), time.Now().Add(5*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.
We need to have this function receive a context, and to have the WriteControl respect that ( somehow ).
We don't want to have a "stuck" endpoint to hang our shutdown process.
sorry - I know it's not easy to implement ;-(
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.
It has a deadline (now + 5 seconds). How this is called in wsNetwork.go will start a thread per peer, so they'll all wait those 5 seconds in parallel and so at most 5 seconds after WebsocketNetwork.Close() is called it should be done.
I agree in principle, it would be neat to upgrade all of websocket to Write and Read with context. Can we punt for a separate soonish TODO issue?
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.
of course. This change is a great improvement on its own and shouldn't be deferred.
We can make it even better tomorrow ;-)
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.
LGTM
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.
Want to confirm the answer to my question before this gets checked in
…eedback TEAL Debugger: address PR feedback: use net/url to parse URL, close response body
Summary
Eliminate warning message when a client disconnects normally.
Test Plan
I made a private 3 node network. I watched the logs on the relay node while
kill
orkill -9
of a leaf node.kill -9
of a node caused a warning message that a node went away unexpectedly, but regularkill
exited the node gracefully such that it sent a websocket CloseMessage and the relay node logged no warning.