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

safely run

上级 4d9148df
......@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"os"
"runtime/debug"
"strconv"
"github.com/gin-gonic/gin"
......@@ -19,6 +18,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/rd/nacos"
"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/xsf"
......@@ -53,7 +53,7 @@ type Application struct {
}
func (x *Application) Run() {
defer Recover()
defer goutils.Recover()
parseInit()
services := CreateServices(x.h())
closes := Close(services)
......@@ -62,12 +62,6 @@ func (x *Application) 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 {
return &Application{
h: h,
......
......@@ -3,6 +3,7 @@ app:
env: "dev"
version: "v0.0.1"
host: "0.0.0.0"
contextPath: "/qituAdmin"
middleware:
cors:
enable: true
......@@ -117,7 +118,7 @@ auth:
signKey: 6m2KywHIPEaWWIxffGpp8Dfl3z5SjE5WeeDStc1T64klnpoAqHrHN01vneteCAGE
cron:
type: xxl
type: xxl # db or xxl
enable: true
schema: operator
xxl:
......@@ -135,6 +136,30 @@ oss:
bucket-url: https://dev-athena.oss-cn-hangzhou.aliyuncs.com
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:
baofu:
bct-terminal-id: ""
......
......@@ -11,6 +11,7 @@ const (
API_GET_BY_ID = "getByID"
API_GET_BY_IDS = "getByIDs"
API_PAGE = "page"
API_EXPORT_CSV = "exportCSV"
)
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论