Browse Source

Run params by ENV vars (will be usefull for Docker)

Vova Tkach 6 years ago
parent
commit
c6d4e467c2
1 changed files with 17 additions and 0 deletions
  1. 17 0
      main.go

+ 17 - 0
main.go

@@ -32,6 +32,23 @@ func init() {
 }
 
 func main() {
+	// Universal, params by env vars
+	if ParamHost == "0.0.0.0" {
+		if os.Getenv("FAVE_HOST") != "" {
+			ParamHost = os.Getenv("FAVE_HOST")
+		}
+	}
+	if ParamPort == 8080 {
+		if os.Getenv("FAVE_PORT") != "" {
+			ParamPort = utils.StrToInt(os.Getenv("FAVE_PORT"))
+		}
+	}
+	if ParamWwwDir == "" {
+		if os.Getenv("FAVE_DIR") != "" {
+			ParamWwwDir = os.Getenv("FAVE_DIR")
+		}
+	}
+
 	// Init logger
 	lg := logger.New()
 	defer lg.Close()