-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
49 lines (38 loc) · 843 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"flag"
"fmt"
"os"
"strconv"
"github.com/21hack02win/nascalay-backend/infrastructure"
"github.com/21hack02win/nascalay-backend/util/logger"
"github.com/labstack/echo/v4"
"github.com/labstack/gommon/log"
)
var (
baseEndpoint string
isDebugMode bool
)
func main() {
flag.StringVar(&baseEndpoint, "b", "", "Custom base endpoint .e.g \"/api\"")
flag.BoolVar(&isDebugMode, "d", false, "Debug mode")
flag.Parse()
e := echo.New()
if isDebugMode {
e.Logger.SetLevel(log.DEBUG)
} else {
e.Logger.SetLevel(log.ERROR)
}
logger.Echo = e.Logger
infrastructure.Setup(e, baseEndpoint)
e.Logger.Fatal(e.Start(port()))
}
func port() string {
p := 3000
if env := os.Getenv("APP_PORT"); len(env) > 0 {
if port, err := strconv.Atoi(env); err == nil {
p = port
}
}
return fmt.Sprintf(":%d", p)
}