-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (44 loc) · 1.09 KB
/
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
50
51
52
53
54
55
56
57
package main
import (
"time"
"github.com/gofiber/contrib/fiberzap/v2"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"pentag.kr/distimer/configs"
"pentag.kr/distimer/db"
"pentag.kr/distimer/routers"
"pentag.kr/distimer/schedulers"
"pentag.kr/distimer/utils/logger"
)
func main() {
location, err := time.LoadLocation("Asia/Seoul")
if err != nil {
panic(err)
}
// Set the timezone for the current process
time.Local = location
// Load environment variables
configs.LoadEnv()
// Initialize logger
logger.InitLogger(configs.Env.LogLevel)
logger.Debug(time.Now().Format(time.RFC3339))
// Connect database client
db.ConnectDBClient()
schedulerObj := schedulers.GenerateSchedularObj()
schedulerObj.Start()
app := fiber.New(fiber.Config{
ProxyHeader: "CF-Connecting-IP",
})
app.Use(cors.New(cors.Config{
AllowOrigins: "*",
AllowHeaders: "*",
AllowMethods: "*",
}))
app.Use(fiberzap.New(fiberzap.Config{
Logger: logger.MyLogger,
}))
// Register routers
routers.EnrollRouter(app)
logger.Fatal(app.Listen(":3000"))
schedulerObj.Stop()
}