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
|
| MaxSendMsgSize int `mapstructure:"max-send-msg-size"` | ||
| } | ||
|
|
||
| // RESTConfig defines configuration for the rest server. |
There was a problem hiding this comment.
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.
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.
| rpcPort = 26657 | ||
| apiPort = 1317 | ||
| grpcPort = 9090 | ||
| restPort = 8080 |
There was a problem hiding this comment.
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.
🛠️ 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 |
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.mdReviewers 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
singleMachineflag for improved REST server operation in single-host configurations.