FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Refactor of main to allow graceful shutdown by r4f4ss · Pull Request #158 · optimism-java/shisui · GitHub

Refactor of main to allow graceful shutdown - #158

Merged
fearlessfe merged 6 commits into
optimism-java:portalfrom
r4f4ss:graceful-shutdown
Sep 19, 2024
Merged

Refactor of main to allow graceful shutdown#158
fearlessfe merged 6 commits into
optimism-java:portalfrom
r4f4ss:graceful-shutdown

Conversation

r4f4ss commented Sep 17, 2024

Copy link
Copy Markdown

solves #156

Copy link
Copy Markdown
Member

Since we forked geth, is there any existing code to reuse or reference.

Comment thread cmd/shisui/main.go
}

type Client struct {
DiscV5API *discover.DiscV5API

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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:

func (t *UDPv5) Close() {

r4f4ss commented Sep 18, 2024
edited
Loading

Copy link
Copy Markdown
Author

Since we forked geth, is there any existing code to reuse or reference.

The reference comes from

func StartNode(ctx *cli.Context, stack *node.Node, isConsole bool) {
that geth main function calls to create a new node. Inside this function (StartNode) a goroutine watches a channel for signals of interruption and executes the shutdown function (
shutdown()
).

I studied this file to understand how to handle a syscall.SIGINT or a syscall.SIGTERM signals, but I believe it is not possible to reuse this code to deal with Shisui since geth implements an anonymous goroutine.

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.

fearlessfe merged commit 4a93362 into optimism-java:portal Sep 19, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL