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

support Wildcards IP #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (

var (
port = flag.Int("port", 8080, "Example app port.")
appdashPort = flag.Int("appdash.port", 8700, "Run appdash locally on this port.")
appdashAddr = flag.String("appdash.addr", "localhost", "Run appdash on this addr.")
appdashPort = flag.Int("appdash.port", 8700, "Run appdash on this port.")
lightstepToken = flag.String("lightstep.token", "", "Lightstep access token.")
)

Expand All @@ -28,7 +29,8 @@ func main() {
if len(*lightstepToken) > 0 {
tracer = lightstepot.NewTracer(lightstepot.Options{AccessToken: *lightstepToken})
} else {
addr := startAppdashServer(*appdashPort)
appdashHost := fmt.Sprintf("%s:%d", *appdashAddr,*appdashPort)
addr := startAppdashServer(appdashHost)
tracer = appdashot.NewTracer(appdash.NewRemoteCollector(addr))
}

Expand All @@ -41,6 +43,6 @@ func main() {
mux.HandleFunc("/async", serviceHandler)
mux.HandleFunc("/service", serviceHandler)
mux.HandleFunc("/db", dbHandler)
fmt.Printf("Go to http://localhost:%d/home to start a request!\n", *port)
fmt.Printf("Go to http://%s:%d/home to start a request!\n", *appdashAddr, *port)
log.Fatal(http.ListenAndServe(addr, mux))
}
8 changes: 4 additions & 4 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

// Returns the remote collector address.
func startAppdashServer(appdashPort int) string {
func startAppdashServer(appdashPort string) string {
store := appdash.NewMemoryStore()

// Listen on any available TCP port locally.
l, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
l, err := net.ListenTCP("tcp", &net.TCPAddr{IP: []byte(""), Port: 0})
if err != nil {
log.Fatal(err)
}
Expand All @@ -28,7 +28,7 @@ func startAppdashServer(appdashPort int) string {
go cs.Start()

// Print the URL at which the web UI will be running.
appdashURLStr := fmt.Sprintf("http://localhost:%d", appdashPort)
appdashURLStr := fmt.Sprintf("http://%s", appdashPort)
appdashURL, err := url.Parse(appdashURLStr)
if err != nil {
log.Fatalf("Error parsing %s: %s", appdashURLStr, err)
Expand All @@ -43,7 +43,7 @@ func startAppdashServer(appdashPort int) string {
tapp.Store = store
tapp.Queryer = store
go func() {
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", appdashPort), tapp))
log.Fatal(http.ListenAndServe(fmt.Sprintf("%s", appdashPort), tapp))
}()
return fmt.Sprintf(":%d", collectorPort)
}