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

multiple ports are listened to when starting the debug agent #5633

Closed
myron369 opened this issue Feb 8, 2025 · 1 comment
Closed

multiple ports are listened to when starting the debug agent #5633

myron369 opened this issue Feb 8, 2025 · 1 comment

Comments

@myron369
Copy link

myron369 commented Feb 8, 2025

When starting the debug agent, multiple ports from 6060 to 6100 are being listened to. Is the intention here to avoid a single port being occupied? If so, it seems that the behavior should be modified so that once a successful ListenAndServe (encountering a free port) occurs, the process should stop occupying additional ports.I can help fix it (if it is indeed a bug).

        // cmd/main.go
	if !c.Bool("no-agent") {
		go debugAgentOnce.Do(func() {
			for port := 6060; port < 6100; port++ {
				debugAgent = fmt.Sprintf("127.0.0.1:%d", port)
				logger.Debugf("Debug agent listening on %s", debugAgent)
				_ = http.ListenAndServe(debugAgent, nil)
			}
		})
	}
@myron369 myron369 added the kind/bug Something isn't working label Feb 8, 2025
@jiefenghuang
Copy link
Contributor

ListenAndServe will block and loop to handle HTTP requests without occupying other ports. When the process exits, it will terminate along with it.

@jiefenghuang jiefenghuang removed the kind/bug Something isn't working label Feb 10, 2025
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

No branches or pull requests

2 participants