|
@@ -14,10 +14,10 @@ import (
|
|
_ "net/http/pprof"
|
|
_ "net/http/pprof"
|
|
"os"
|
|
"os"
|
|
"strings"
|
|
"strings"
|
|
-
|
|
|
|
//"unsafe"
|
|
//"unsafe"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+// sss
|
|
// @title 科湃腾Go语言后台API
|
|
// @title 科湃腾Go语言后台API
|
|
// @version 1.1.2
|
|
// @version 1.1.2
|
|
// @description kptyun_service
|
|
// @description kptyun_service
|
|
@@ -34,14 +34,14 @@ func main() {
|
|
logging.Setup()
|
|
logging.Setup()
|
|
|
|
|
|
svcConfig := &service.Config{
|
|
svcConfig := &service.Config{
|
|
- Name: setting.ServerSetting.ServerName, //服务显示名称
|
|
|
|
- DisplayName: setting.ServerSetting.DisplayName, //服务名称
|
|
|
|
- Description: setting.ServerSetting.Description, //服务描述
|
|
|
|
|
|
+ Name: setting.ServerSetting.ServerName, //服务显示名称
|
|
|
|
+ DisplayName: setting.ServerSetting.DisplayName, //服务名称
|
|
|
|
+ Description: setting.ServerSetting.Description, //服务描述
|
|
}
|
|
}
|
|
prg := &program{}
|
|
prg := &program{}
|
|
s, err := service.New(prg, svcConfig)
|
|
s, err := service.New(prg, svcConfig)
|
|
if err != nil {
|
|
if err != nil {
|
|
- fmt.Println(err, "service.New() err",err)
|
|
|
|
|
|
+ fmt.Println(err, "service.New() err", err)
|
|
}
|
|
}
|
|
|
|
|
|
if len(os.Args) > 1 {
|
|
if len(os.Args) > 1 {
|
|
@@ -72,9 +72,8 @@ func main() {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
type program struct{}
|
|
type program struct{}
|
|
|
|
+
|
|
func (p *program) Start(s service.Service) error {
|
|
func (p *program) Start(s service.Service) error {
|
|
go p.run()
|
|
go p.run()
|
|
return nil
|
|
return nil
|
|
@@ -85,7 +84,7 @@ func (p *program) run() {
|
|
|
|
|
|
//路由初始化
|
|
//路由初始化
|
|
routersInit := routers.InitRouter()
|
|
routersInit := routers.InitRouter()
|
|
- if setting.ServerSetting.GRFD == "1"{ //格润富德定时任务
|
|
|
|
|
|
+ if setting.ServerSetting.GRFD == "1" { //格润富德定时任务
|
|
api.CronGRFD()
|
|
api.CronGRFD()
|
|
}
|
|
}
|
|
readTimeout := setting.ServerSetting.ReadTimeout
|
|
readTimeout := setting.ServerSetting.ReadTimeout
|
|
@@ -107,14 +106,14 @@ func (p *program) run() {
|
|
}
|
|
}
|
|
httpsPort := fmt.Sprintf(":%d", setting.ServerSetting.HttpsPort)
|
|
httpsPort := fmt.Sprintf(":%d", setting.ServerSetting.HttpsPort)
|
|
// 开启http/https服务
|
|
// 开启http/https服务
|
|
- if setting.ServerSetting.Https == 1{
|
|
|
|
|
|
+ if setting.ServerSetting.Https == 1 {
|
|
log.Printf("[info] start https server listening port %s", httpsPort)
|
|
log.Printf("[info] start https server listening port %s", httpsPort)
|
|
- _ =routersInit.RunTLS(httpsPort, setting.ServerSetting.CrtPath, setting.ServerSetting.KeyPath)
|
|
|
|
- }else if setting.ServerSetting.Https == 2{
|
|
|
|
- log.Printf("[info] start https & http server listening port https %s, http %s", httpsPort,endPoint)
|
|
|
|
|
|
+ _ = routersInit.RunTLS(httpsPort, setting.ServerSetting.CrtPath, setting.ServerSetting.KeyPath)
|
|
|
|
+ } else if setting.ServerSetting.Https == 2 {
|
|
|
|
+ log.Printf("[info] start https & http server listening port https %s, http %s", httpsPort, endPoint)
|
|
go routersInit.RunTLS(httpsPort, setting.ServerSetting.CrtPath, setting.ServerSetting.KeyPath)
|
|
go routersInit.RunTLS(httpsPort, setting.ServerSetting.CrtPath, setting.ServerSetting.KeyPath)
|
|
_ = server.ListenAndServe()
|
|
_ = server.ListenAndServe()
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
log.Printf("[info] start https server listening port %s", endPoint)
|
|
log.Printf("[info] start https server listening port %s", endPoint)
|
|
_ = server.ListenAndServe()
|
|
_ = server.ListenAndServe()
|
|
}
|
|
}
|