-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
added automatic portChange feature if current port is busy #1066
Conversation
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
Apply Sweep Rules to your PR?
|
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.
Looks good to me
What if the next port is in use by some other running service? A while loop with a random function to generate port would be better I believe |
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
12fd8ab
to
dcf5cb2
Compare
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.
Please address the comments
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
d474820
to
767221f
Compare
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.
Please address the comment
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
301602b
to
dd880ea
Compare
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.
Please address the comments, rest looks fine.
pkg/proxy/proxy.go
Outdated
for i := 1024; i <= 65535 && attemptsDone < maxAttempts; i++ { | ||
if isPortAvailable(uint32(i)) { | ||
opt.Port = uint32(i) | ||
logger.Info(Emoji+"Port %v is already in use, switching to next available port"); |
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.
I don't think we need emoji here it is already appended when we initialise logger and include the port number which you are switching to in the log.
pkg/proxy/proxy.go
Outdated
} | ||
|
||
if maxAttempts<=attemptsDone{ | ||
logger.Error(Emoji+"Failed to find an available port to start proxy 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.
Remove the emoji.
pkg/proxy/proxy.go
Outdated
} | ||
} | ||
|
||
if maxAttempts<=attemptsDone{ |
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.
beautify the statement I guess there must be spaces before and after the <= symbol. There must be some extension in the IDE you can use it and make sure it is indentation is correct.
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
ffd6221
to
4048abb
Compare
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.
Please address the comment.
pkg/proxy/proxy.go
Outdated
//IPv4 | ||
localIp4, err := util.GetLocalIPv4() | ||
if err != nil { | ||
log.Fatalln(Emoji+"Failed to get the local Ip4 address", err) | ||
log.Fatalln("Failed to get the local Ip4 address", err) |
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.
Why is it removed from here? This is not zap.logger, It is just log. Here we should use emoji.
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
pkg/proxy/proxy.go
Outdated
|
||
if !isPortAvailable(opt.Port) { | ||
logger.Info("Port is already in use, switching to next available port",zap.Uint32("port",opt.Port)); |
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.
Port is already in use, switching to next available port {port : 16789}
this is how the logger looks when you run keploy. It gives a sense that you found that the port is already in use and you are switching to port 16789 which is wrong. You can delete this log or correct it . Deleting this log makes more sense for me.
Signed-off-by: EraKin575 <tejaskumar574@gmail.com>
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.
ship it!
Related Issue
Closes: #1051
Describe the changes you've made
added a automatic port changing feature for test and record mode if current port is busy
![image](https://private-user-images.githubusercontent.com/100225222/280224878-79a530db-49a4-43a9-bff7-f3bd4e6a6163.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEzNzY1MDEsIm5iZiI6MTcyMTM3NjIwMSwicGF0aCI6Ii8xMDAyMjUyMjIvMjgwMjI0ODc4LTc5YTUzMGRiLTQ5YTQtNDNhOS1iZmY3LWYzYmQ0ZTZhNjE2My5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzE5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcxOVQwODAzMjFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kZjk4OTliMjM5MGI5YjVkZDRiM2Y5MDQxZDRmNTEyNjVmN2UyYTI2Y2U0NmY1NzdiZTZjZTMzYThiYWYzOWZmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.775btmJNzX7c6htlk2br3jWvCIVJThWFG0YEH_-Fm9M)
Type of change
Please let us know if any test cases are added
Please describe the tests(if any). Provide instructions how its affecting the coverage.
Describe if there is any unusual behaviour of your code(Write
NA
if there isn't)A clear and concise description of it.
Checklist:
Screenshots (if any)