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

feat: dashboard supports random port #205

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cmd/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io"
"log"
"net"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -114,14 +115,18 @@ func RunWebServer(port int, isDockerCompose bool, componentsPath string, configP
spa := spaHandler{staticPath: "web/dist", indexPath: "index.html"}
r.PathPrefix("/").Handler(spa)

listener, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%v", port))
if err != nil {
log.Fatal(err)
}
port = listener.Addr().(*net.TCPAddr).Port
srv := &http.Server{
Handler: r,
Addr: fmt.Sprintf("0.0.0.0:%v", port),
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
fmt.Printf("Dapr Dashboard running on http://localhost:%v\n", port)
log.Fatal(srv.ListenAndServe())
log.Fatal(srv.Serve(listener))
}

// ServeHTTP inspects the URL path to locate a file within the static dir
Expand Down
Loading