-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (37 loc) · 876 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
package main
import (
"fmt"
"gin-gorm-base/crontab"
"gin-gorm-base/pkg/util"
"github.com/gin-gonic/gin"
"log"
"net/http"
"gin-gorm-base/models"
"gin-gorm-base/pkg/gredis"
"gin-gorm-base/pkg/logging"
"gin-gorm-base/pkg/setting"
"gin-gorm-base/routers"
)
func init() {
gin.SetMode(setting.ServerSetting.RunMode)
setting.Setup()
logging.Setup()
gredis.Setup()
util.Setup()
models.Setup()
crontab.SetUp()
}
func main() {
routersInit := routers.InitRouter()
readTimeout := setting.ServerSetting.ReadTimeout
writeTimeout := setting.ServerSetting.WriteTimeout
endPoint := fmt.Sprintf(":%d", setting.ServerSetting.HttpPort)
server := &http.Server{
Addr: endPoint,
Handler: routersInit,
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
}
log.Printf("[info] start http server listening %s", endPoint)
server.ListenAndServe()
}