1
0
mirror of https://github.com/thebaer/cdr.git synced 2024-11-15 01:31:01 +00:00

Support setting server port with PORT env var

This also logs the address the application is serving on.
This commit is contained in:
Matt Baer 2020-02-29 09:20:24 -05:00
parent a28732063f
commit 82650d00ae

View File

@ -92,5 +92,10 @@ func serveAction(c *cli.Context) error {
log.Printf("GET /") log.Printf("GET /")
}) })
return http.ListenAndServe(":9991", nil) port := os.Getenv("PORT")
if port == "" {
port = "9991"
}
log.Printf("Serving on http://localhost:%s", port)
return http.ListenAndServe(":"+port, nil)
} }