-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (33 loc) · 811 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
package main
import (
"log"
"github.com/gin-gonic/gin"
"github.com/ARMeeru/time-capsule/config"
"github.com/ARMeeru/time-capsule/routes"
"github.com/ARMeeru/time-capsule/utils"
)
func main() {
// Load environment variables
config.LoadEnv()
// Connect to the database
utils.ConnectDatabase()
// Start the scheduler
go utils.StartScheduler()
// Set up the Gin router
router := gin.Default()
// Initialize routes
routes.InitRoutes(router)
// Start the server
port := config.GetEnv("APP_PORT")
if port == "" {
port = ":8080"
log.Printf("APP_PORT not specified. Using default port%s", port)
} else {
port = ":" + port
log.Printf("Server is running on http://localhost%s", port)
}
err := router.Run(port)
if err != nil {
log.Fatalf("Failed to start the server: %v", err)
}
}