-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
45 lines (39 loc) · 864 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
package main
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"healthy/app/midwares"
"healthy/app/services/taskService"
"healthy/config/config"
"healthy/config/router"
"healthy/config/task"
"log"
"os"
"os/signal"
"syscall"
)
func main() {
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
go func() {
r := gin.Default()
r.Use(cors.Default())
r.Use(midwares.ErrHandler())
r.NoMethod(midwares.HandleNotFound)
r.NoRoute(midwares.HandleNotFound)
router.Init(r)
if err := r.Run(":" + config.Config.GetString("port")); err != nil {
log.Fatal("gin Server Start Failed", err)
}
}()
go func() {
mux, err := taskService.Init()
if err != nil {
log.Fatal(err)
}
if err = task.AsynqServer.Run(mux); err != nil {
log.Fatal("mq server start failed", err)
}
}()
<-stop
}