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

feat: cleanup server start function #16208

Closed
wants to merge 2 commits into from
Closed

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented May 18, 2023

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@yihuang yihuang requested a review from a team as a code owner May 18, 2023 08:32
@github-prbot github-prbot requested review from a team, aaronc and likhita-809 and removed request for a team May 18, 2023 08:33
@@ -249,7 +249,7 @@ func startStandAlone(svrCtx *Context, appCreator types.AppCreator) error {
g, ctx := errgroup.WithContext(ctx)

// listen for quit signals so the calling parent process can gracefully exit
ListenForQuitSignals(cancelFn, svrCtx.Logger)
ListenForQuitSignals(g, cancelFn, svrCtx.Logger)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

start the signal listening goroutine in the group, so the group is never empty.

g.Go(func() error {
<-ctx.Done()
return nil
})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the signal listening goroutine is started in the group, so the group is never empty.

if traceWriterCleanup != nil {
traceWriterCleanup()
}
}()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the big defer function is broken up into smaller pieces, and put right after the respective resource is created.

}()

return <-errCh
return callbackFn()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

equivalent code.

nodeKey, err := p2p.LoadOrGenNodeKey(cmtCfg.NodeKeyFile())
if err != nil {
return err
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the code is moved according to the TODO note.

@alexanderbez
Copy link
Contributor

Have these changes been tested on a node? Preferably in various conditions (gRPC only, API and/or gRPC enabled/disabled).

@yihuang yihuang added backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release labels May 19, 2023
@yihuang
Copy link
Collaborator Author

yihuang commented May 19, 2023

Have these changes been tested on a node? Preferably in various conditions (gRPC only, API and/or gRPC enabled/disabled).

I just tried on a local devnet node (starting the node in foreground, and interrupted with Ctl+C), with different configs and --grpc-only flag, all works alright.

@tac0turtle
Copy link
Member

should we close this in favour of #16238 or wait for it be merged?

@ValarDragon
Copy link
Contributor

This PR has another improvement not in #16238, for getting the errorgroup handled better than today. (Putting listenForQuitSignals into the errorgroup, and removing the confusing dummy errorgroup wait)

That should def get in, but maybe it makes more sense after 16238 is merged?

@yihuang
Copy link
Collaborator Author

yihuang commented May 22, 2023

I think it's easier that @ValarDragon take what's useful into #16238, and we can close this one.

@ValarDragon
Copy link
Contributor

Ok!

@yihuang yihuang closed this May 23, 2023
@yihuang yihuang deleted the cleanup-server branch May 23, 2023 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.47.x PR scheduled for inclusion in the v0.47's next stable release backport/0.46.x PR scheduled for inclusion in the v0.46's next stable release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants