提交 da5dda94 authored 作者: mooncake9527's avatar mooncake9527

safely run

上级 4d9148df
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"os" "os"
"runtime/debug"
"strconv" "strconv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
...@@ -19,6 +18,7 @@ import ( ...@@ -19,6 +18,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror" "gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos" "gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/dxsf" "gitlab.wanzhuangkj.com/tush/xpkg/utils/dxsf"
goutils "gitlab.wanzhuangkj.com/tush/xpkg/utils/go_utils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils" "gitlab.wanzhuangkj.com/tush/xpkg/utils/sliceUtils"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf" "gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
...@@ -53,7 +53,7 @@ type Application struct { ...@@ -53,7 +53,7 @@ type Application struct {
} }
func (x *Application) Run() { func (x *Application) Run() {
defer Recover() defer goutils.Recover()
parseInit() parseInit()
services := CreateServices(x.h()) services := CreateServices(x.h())
closes := Close(services) closes := Close(services)
...@@ -62,12 +62,6 @@ func (x *Application) Run() { ...@@ -62,12 +62,6 @@ func (x *Application) Run() {
x.app.Run() x.app.Run()
} }
func Recover() {
if r := recover(); r != nil {
logger.Fatalf("Recovered panic: %v\nStack trace:\n%s", r, string(debug.Stack()))
}
}
func New(h func() *gin.Engine) *Application { func New(h func() *gin.Engine) *Application {
return &Application{ return &Application{
h: h, h: h,
......
...@@ -3,6 +3,7 @@ app: ...@@ -3,6 +3,7 @@ app:
env: "dev" env: "dev"
version: "v0.0.1" version: "v0.0.1"
host: "0.0.0.0" host: "0.0.0.0"
contextPath: "/qituAdmin"
middleware: middleware:
cors: cors:
enable: true enable: true
...@@ -117,7 +118,7 @@ auth: ...@@ -117,7 +118,7 @@ auth:
signKey: 6m2KywHIPEaWWIxffGpp8Dfl3z5SjE5WeeDStc1T64klnpoAqHrHN01vneteCAGE signKey: 6m2KywHIPEaWWIxffGpp8Dfl3z5SjE5WeeDStc1T64klnpoAqHrHN01vneteCAGE
cron: cron:
type: xxl type: xxl # db or xxl
enable: true enable: true
schema: operator schema: operator
xxl: xxl:
...@@ -135,6 +136,30 @@ oss: ...@@ -135,6 +136,30 @@ oss:
bucket-url: https://dev-athena.oss-cn-hangzhou.aliyuncs.com bucket-url: https://dev-athena.oss-cn-hangzhou.aliyuncs.com
extend: extend:
rpc:
athena:
srvAddr: http://athena.qitu
groups:
- name: bike
apis:
- name: create
uri: /internal/athena/api/v1/bike/create
- name: deleteByID
uri: /internal/athena/api/v1/bike/deleteByID
- name: deleteByIDs
uri: /internal/athena/api/v1/bike/deleteByIDs
- name: updateByID
uri: /internal/athena/api/v1/bike/updateByID
- name: updateByIDs
uri: /internal/athena/api/v1/bike/updateByIDs
- name: getByID
uri: /internal/athena/api/v1/bike/getByID
- name: getByIDs
uri: /internal/athena/api/v1/bike/getByIDs
- name: page
uri: /internal/athena/api/v1/bike/page
- name: exportCSV
uri: /internal/athena/api/v1/bike/export/csv
third-party: third-party:
baofu: baofu:
bct-terminal-id: "" bct-terminal-id: ""
......
...@@ -11,6 +11,7 @@ const ( ...@@ -11,6 +11,7 @@ const (
API_GET_BY_ID = "getByID" API_GET_BY_ID = "getByID"
API_GET_BY_IDS = "getByIDs" API_GET_BY_IDS = "getByIDs"
API_PAGE = "page" API_PAGE = "page"
API_EXPORT_CSV = "exportCSV"
) )
var ErrApiNotExist = errors.New("theapi not exist") var ErrApiNotExist = errors.New("theapi not exist")
package goutils
import (
"runtime/debug"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
)
func Recover() {
if r := recover(); r != nil {
logger.Fatalf("Recovered panic: %v\nStack trace:\n%s", r, string(debug.Stack()))
}
}
func Safely(f func()) {
go func() {
defer Recover()
f()
}()
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论