Commit e3232dce authored by Bengfort's avatar Bengfort
Browse files

use environment variables instead of command line flags

parent 0bd23860
package main package main
import ( import (
"flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
...@@ -191,19 +190,15 @@ func handler(w http.ResponseWriter, r *http.Request) { ...@@ -191,19 +190,15 @@ func handler(w http.ResponseWriter, r *http.Request) {
} }
func main() { func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "foo [-v] [port]\n")
flag.PrintDefaults()
}
flag.BoolVar(&verbose, "v", false, "enable verbose logs")
flag.Parse()
addr := "localhost:8001" addr := "localhost:8001"
if len(flag.Args()) > 0 {
addr = fmt.Sprintf("localhost:%s", flag.Args()[0]) port, ok := os.LookupEnv("BROKER_PORT")
if ok {
addr = fmt.Sprintf("localhost:%s", port)
} }
_, verbose = os.LookupEnv("BROKER_VERBOSE")
http.HandleFunc("/", handler) http.HandleFunc("/", handler)
log.Printf("Serving on http://%s", addr) log.Printf("Serving on http://%s", addr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment