-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix(simapp/v2): failed to start HTTP server on port 8080 conflict #22687
Conversation
prevent simd panic on restart when access db closed by fail server start
📝 WalkthroughWalkthroughThe changes in this pull request enhance the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
server/config/config.go
Outdated
@@ -141,6 +141,15 @@ type GRPCConfig struct { | |||
MaxSendMsgSize int `mapstructure:"max-send-msg-size"` | |||
} | |||
|
|||
// RESTConfig defines configuration for the rest server. |
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.
What is it used for? That new server is only used in v2. I think the changes are only needed for simappv2 then
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.
Makes sense, thanks!
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.
Actionable comments posted: 2
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
📒 Files selected for processing (1)
simapp/v2/simdv2/cmd/testnet.go
(5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
simapp/v2/simdv2/cmd/testnet.go (1)
Pattern **/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
🔇 Additional comments (3)
simapp/v2/simdv2/cmd/testnet.go (3)
23-23
: Importing REST API package is appropriate
The added import statement for the REST API package is necessary for configuring the REST server functionality.
197-197
: Initializing REST server configuration is appropriate
Initializing restConfig
with rest.DefaultConfig()
correctly sets up the default configuration for the REST server.
349-350
: Integrating REST server into server configuration is appropriate
Including the restServer
in the server initialization ensures that the REST API is properly set up alongside other services.
@@ -184,6 +185,7 @@ func initTestnetFiles[T transaction.Tx]( | |||
rpcPort = 26657 | |||
apiPort = 1317 | |||
grpcPort = 9090 | |||
restPort = 8080 |
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.
Using fixed port 8080
for REST server may cause port conflicts
Defining restPort
as a constant with the value 8080
could lead to port conflicts since port 8080
is commonly used by other services. Consider making the REST port configurable or choosing an uncommon default port to avoid potential conflicts.
|
||
restConfig = &rest.Config{ | ||
Enable: true, | ||
Address: fmt.Sprintf("127.0.0.1:%d", restPort+portOffset), | ||
} |
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.
🛠️ Refactor suggestion
Potential port conflicts in multi-host configurations
The REST server is configured to listen on 127.0.0.1
at port restPort + portOffset
when singleMachine
is set to true
, which helps avoid port conflicts on a single machine. However, when singleMachine
is false
, the portOffset
is not applied, and all instances will listen on the same restPort
(port 8080
) on their respective hosts. If multiple instances are running on the same host or if port 8080
is already in use on any host, this could cause port conflicts.
Suggestion: Make the REST port configurable or apply portOffset
in multi-host setups
To prevent potential port conflicts in multi-host configurations, consider making the REST port configurable regardless of the singleMachine
flag or apply the portOffset
in both scenarios.
seems there is a suplicate import, can you fix and then we can merge it |
…ckport #22687) (#22711) Co-authored-by: mmsqe <[email protected]>
prevent simdv2 panic on restart when access db closed by fail server start
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...
!
in the type prefix if API or client breaking changeCHANGELOG.md
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.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
8080
.Bug Fixes
singleMachine
flag for improved REST server operation in single-host configurations.