params.go 718 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "os"
  4. "golang-fave/engine/consts"
  5. "golang-fave/utils"
  6. )
  7. func read_env_params() {
  8. if consts.ParamHost == "0.0.0.0" {
  9. if os.Getenv("FAVE_HOST") != "" {
  10. consts.ParamHost = os.Getenv("FAVE_HOST")
  11. }
  12. }
  13. if consts.ParamPort == 8080 {
  14. if os.Getenv("FAVE_PORT") != "" {
  15. consts.ParamPort = utils.StrToInt(os.Getenv("FAVE_PORT"))
  16. }
  17. }
  18. if consts.ParamWwwDir == "" {
  19. if os.Getenv("FAVE_DIR") != "" {
  20. consts.ParamWwwDir = os.Getenv("FAVE_DIR")
  21. }
  22. }
  23. if consts.ParamDebug == false {
  24. if os.Getenv("FAVE_DEBUG") == "true" {
  25. consts.ParamDebug = true
  26. }
  27. }
  28. if consts.ParamKeepAlive == false {
  29. if os.Getenv("FAVE_KEEPALIVE") == "true" {
  30. consts.ParamKeepAlive = true
  31. }
  32. }
  33. }