-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (61 loc) · 1.59 KB
/
main.go
File metadata and controls
66 lines (61 loc) · 1.59 KB
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
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"net/http"
"time"
"zldface_server/cache"
"zldface_server/config"
"zldface_server/recognition"
"zldface_server/router"
)
type server interface {
ListenAndServe() error
}
func initServer(address string, router *gin.Engine) server {
return &http.Server{
Addr: address,
Handler: router,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
}
func runserver() {
Router := router.Routers()
//request.RegisterValidations()
//Router.Static("/form-generator", "./resource/page")
address := fmt.Sprintf(":%d", config.Config.System.Addr)
s := initServer(address, Router)
time.Sleep(10 * time.Microsecond)
config.Logger.Info("server run success on ", zap.String("address", address))
config.Logger.Error(s.ListenAndServe().Error())
}
// @title 智链达人脸录入和识别服务API
// @version 1.0
// @description This a face recognition server using arcsoft face engine
// @contact.name DengLingfei
// @contact.email denglingfei@zlddata.cn
// @license.name Apache2.0
// @host localhost:8888
// @BasePath /face/
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
config.Logger.Info(fmt.Sprintf("%v", config.Config))
cache.BeRun()
arcEngine, err := recognition.NewEngine()
if err != nil {
config.Logger.Error(fmt.Sprintf("人脸识别引擎加载错误:%s", err.Error()))
} else {
arcEngine.Destroy()
}
runserver()
db, _ := config.DB.DB()
defer db.Close()
if config.RedisCli != nil {
defer config.RedisCli.Close()
}
}