-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (32 loc) · 844 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
package main
import (
"fmt"
"log"
"net/http"
"time"
"github.com/saltchang/church-music-api/env"
"github.com/saltchang/church-music-api/jobs"
"github.com/saltchang/church-music-api/models"
"github.com/saltchang/church-music-api/routes"
)
var (
r *routes.Routers
db = models.DB
)
func main() {
db.InitDB()
// Create the dummy songs data, just for development
models.DummySongs()
// Initialize and start the health checker
healthChecker := jobs.NewHealthChecker(
env.ENV.MusicAppURL+"/api/health",
5*time.Minute,
)
healthChecker.Start()
// Set the Main Router
mainRouter := r.InitRouters()
// All things are good now, server starts to run
fmt.Println("Environment: ", env.ENV.AppConfig)
fmt.Println("Server starts to run at port: " + env.ENV.Port)
log.Fatal(http.ListenAndServe(":"+env.ENV.Port, mainRouter))
}