From 8770437237cd43b77742a0ac65640958346b7b10 Mon Sep 17 00:00:00 2001 From: Carl Jackson Date: Tue, 6 May 2014 14:25:11 -0700 Subject: [PATCH] Allow bind to be configured through env vars Goji now honors two environment variables: GOJI_BIND (which accepts the full "bind" flag syntax) and PORT (which is treated as a TCP port). Ref #20. --- bind/bind.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bind/bind.go b/bind/bind.go index 60aecc4..3ddf3e6 100644 --- a/bind/bind.go +++ b/bind/bind.go @@ -41,10 +41,14 @@ func init() { systemdInit() defaultBind := ":8000" - if usingEinhorn() { + if bind := os.Getenv("GOJI_BIND"); bind != "" { + defaultBind = bind + } else if usingEinhorn() { defaultBind = "einhorn@0" } else if usingSystemd() { defaultBind = "fd@3" + } else if port := os.Getenv("PORT"); port != "" { + defaultBind = ":" + port } flag.StringVar(&bind, "bind", defaultBind, `Address to bind on. If this value has a colon, as in ":8000" or