44 lines
767 B
Go
44 lines
767 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"myschools.me/suguo/gofound/gin"
|
|
"myschools.me/suguo/gofound/global"
|
|
"myschools.me/suguo/gofound/service"
|
|
)
|
|
|
|
func main() {
|
|
global.Parse()
|
|
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
fmt.Printf("panic: %s\n", r)
|
|
}
|
|
}()
|
|
|
|
//初始化分词器
|
|
tokenizer := service.NewTokenizer(global.CONFIG.Dictionary)
|
|
service.ContainerInit(tokenizer)
|
|
|
|
gin.Service(&gin.Config{
|
|
RootPath: "/api",
|
|
Addr: global.CONFIG.Addr,
|
|
Port: global.CONFIG.Port,
|
|
Ssl: false,
|
|
SslPem: "",
|
|
SslKey: "",
|
|
EnableGzip: true,
|
|
})
|
|
|
|
// 优雅关机
|
|
quit := make(chan os.Signal, 1)
|
|
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
<-quit
|
|
log.Println("Shutdown Server ...")
|
|
}
|