MCPcopy Create free account
hub / github.com/bytebase/bytebase / checkPort

Function checkPort

backend/bin/server/cmd/root.go:137–143  ·  view source on GitHub ↗

Check the port availability by trying to bind and immediately release it.

(port int)

Source from the content-addressed store, hash-verified

135
136// Check the port availability by trying to bind and immediately release it.
137func checkPort(port int) error {
138 l, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port))
139 if err != nil {
140 return err
141 }
142 return l.Close()
143}
144
145func start() {
146 handlerOptions := &slog.HandlerOptions{AddSource: true, Level: log.LogLevel, ReplaceAttr: log.Replace}

Callers 1

startFunction · 0.70

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected