diff --git a/lnme.go b/lnme.go index 2910a0f..8608d13 100644 --- a/lnme.go +++ b/lnme.go @@ -24,6 +24,8 @@ import ( "github.com/labstack/echo/v4/middleware" ) +const DEFAULT_LISTEN = ":1323" + // Middleware for request limited to prevent too many requests // TODO: move to file func LimitMiddleware(lmt *limiter.Limiter) echo.MiddlewareFunc { @@ -185,10 +187,24 @@ func main() { }) port := cfg.String("port") + // Special case for PORT instead of LNME_PORT due to cloud-providers if os.Getenv("PORT") != "" { port = os.Getenv("PORT") } - e.Logger.Fatal(e.Start(":" + port)) + listen := cfg.String("listen") + if listen != "" && port != "" { + log.Fatalf("Port and listen options are mutually exclusive, please just use listen.") + } + if listen == "" { + if port != "" { + stdOutLogger.Printf("Please use listen instead of deprecated port setting.") + listen = fmt.Sprintf(":%s", port) + } else { + listen = DEFAULT_LISTEN + } + } + + e.Logger.Fatal(e.Start(listen)) } func LoadConfig() *koanf.Koanf { @@ -203,7 +219,8 @@ func LoadConfig() *koanf.Koanf { f.Bool("disable-cors", false, "Disable CORS headers.") f.Float64("request-limit", 5, "Request limit per second.") f.String("static-path", "", "Path to a static assets directory.") - f.String("port", "1323", "Port to bind on.") + f.String("port", "", "Port to bind on (deprecated - use listen).") + f.String("listen", "", fmt.Sprintf("Address to bind on. (default \"%s\")", DEFAULT_LISTEN)) var configPath string f.StringVar(&configPath, "config", "config.toml", "Path to a .toml config file.") f.Parse(os.Args[1:])