Skip to content

Commit

Permalink
Allow status to run on alternate ports
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scott committed Feb 26, 2020
1 parent a088757 commit 593cb48
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/puma-dev/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,23 @@ func command() error {
}
}

// App is a running application.
type App struct {
Status string `json:"status"`
Scheme string `json:"scheme"`
Address string `json:"address"`
}

func status() error {
var port string

if *fHTTPPort != 9280 {
port = fmt.Sprintf(":%d", *fHTTPPort)
}

client := &http.Client{}
req, err := http.NewRequest("GET", "http://localhost/status", nil)
url := fmt.Sprintf("http://localhost%s/status", port)
req, err := http.NewRequest("GET", url, nil)
req.Host = "puma-dev"
w := tabwriter.NewWriter(os.Stdout, 20, 4, 1, ' ', 0)

Expand All @@ -45,7 +53,7 @@ func status() error {
res, err := client.Do(req)

if err != nil {
fmt.Println("puma-dev is not running")
fmt.Printf("Unable to lookup puma-dev status. Is puma-dev listening on port %d?\n", *fHTTPPort)
return nil
}

Expand Down

0 comments on commit 593cb48

Please sign in to comment.