Add Docker setup, add environment vars for each flag
This commit is contained in:
@@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
listen := flag.String("listen", ":9091", "gRPC listen address")
|
||||
collectors := flag.String("collectors", "", "comma-separated collector host:port addresses")
|
||||
source := flag.String("source", hostname(), "name for this aggregator in responses")
|
||||
listen := flag.String("listen", envOr("AGGREGATOR_LISTEN", ":9091"), "gRPC listen address (env: AGGREGATOR_LISTEN)")
|
||||
collectors := flag.String("collectors", envOr("AGGREGATOR_COLLECTORS", ""), "comma-separated collector host:port addresses (env: AGGREGATOR_COLLECTORS)")
|
||||
source := flag.String("source", envOr("AGGREGATOR_SOURCE", hostname()), "name for this aggregator in responses (env: AGGREGATOR_SOURCE, default: hostname)")
|
||||
flag.Parse()
|
||||
|
||||
if *collectors == "" {
|
||||
log.Fatal("aggregator: --collectors is required")
|
||||
log.Fatal("aggregator: --collectors / AGGREGATOR_COLLECTORS is required")
|
||||
}
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
@@ -72,3 +72,10 @@ func hostname() string {
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
func envOr(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user