Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doc-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eifel邓鹏飞
doc-service
Commits
9e58d5ac
Commit
9e58d5ac
authored
Sep 18, 2024
by
Bess严根旺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
全局捕获异常
parent
01859617
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
convert_command.go
console/convert_command.go
+10
-0
get_convert_command.go
console/get_convert_command.go
+11
-0
convert_service.go
domain/service/convert_service.go
+9
-0
No files found.
console/convert_command.go
View file @
9e58d5ac
...
...
@@ -7,14 +7,22 @@ import (
service2
"doc-service/domain/repository"
"doc-service/infra/db"
"fmt"
"github.com/nacos-group/nacos-sdk-go/v2/common/logger"
"gitlab.galaxy-immi.com/Backend-group/go-com/third/log"
"os"
"strings"
"time"
)
func
recoverPanicToPro
()
{
if
r
:=
recover
();
r
!=
nil
{
logger
.
Error
(
"执行转换异常"
,
r
)
}
}
// 执行文件转换
func
DoAliData
()
{
defer
recoverPanicToPro
()
fmt
.
Println
(
"开始刷新请求..."
)
ctx
:=
context
.
Background
()
// 启动一个协程来执行定时任务 20秒一次
...
...
@@ -49,6 +57,7 @@ func DoAliData() {
//获取数据
func
toDoData
(
c
context
.
Context
)
int8
{
defer
recoverPanicToPro
()
projectData
,
err
:=
db
.
GetServerSiteMicrosDB
()
.
DocServerProject
.
Query
()
.
Where
(
docserverproject
.
StatusEQ
(
0
),
)
.
All
(
c
)
...
...
@@ -78,6 +87,7 @@ func toDoData(c context.Context) int8 {
// 执行文件转换(脚本使用)
func
DoConversionToAli
(
c
context
.
Context
,
projectId
int32
)
bool
{
defer
recoverPanicToPro
()
ConversionInfo
,
infoErr
:=
db
.
GetServerSiteMicrosDB
()
.
DocServerProject
.
Get
(
c
,
projectId
)
if
infoErr
!=
nil
{
return
false
...
...
console/get_convert_command.go
View file @
9e58d5ac
...
...
@@ -15,8 +15,15 @@ import (
"time"
)
func
recoverPanicGetPro
()
{
if
r
:=
recover
();
r
!=
nil
{
logger
.
Error
(
"获取转换进度异常"
,
r
)
}
}
// 获取转换进度
func
GetConvert
()
{
defer
recoverPanicGetPro
()
fmt
.
Println
(
"开始获取进度..."
)
ctx
:=
context
.
Background
()
// 启动一个协程来执行定时任务
...
...
@@ -49,6 +56,8 @@ func GetConvert() {
}
func
getConvertDoData
(
ctx
context
.
Context
)
int8
{
defer
recoverPanicGetPro
()
list
,
err
:=
db
.
GetServerSiteMicrosDB
()
.
DocServerProject
.
Query
()
.
Where
(
docserverproject
.
StatusEQ
(
1
),
)
.
All
(
ctx
)
...
...
@@ -76,6 +85,8 @@ func getConvertDoData(ctx context.Context) int8 {
}
func
GetProjectInfo
(
c
context
.
Context
,
projectId
int32
)
int8
{
defer
recoverPanicGetPro
()
projectInfo
,
infoErr
:=
db
.
GetServerSiteMicrosDB
()
.
DocServerProject
.
Get
(
c
,
projectId
)
if
infoErr
!=
nil
{
return
0
...
...
domain/service/convert_service.go
View file @
9e58d5ac
...
...
@@ -4,6 +4,7 @@ import (
"context"
service
"doc-service/domain/repository"
"doc-service/infra/db"
"github.com/nacos-group/nacos-sdk-go/v2/common/logger"
pb
"gitlab.galaxy-immi.com/Backend-group/proto/pb/docservice"
"strings"
"time"
...
...
@@ -13,9 +14,16 @@ type DocServiceService struct {
pb
.
UnimplementedDocServiceServiceServer
}
func
recoverPanic
()
{
if
r
:=
recover
();
r
!=
nil
{
logger
.
Error
(
"异常了"
,
r
)
}
}
// 发起文件转换
func
(
doc
*
DocServiceService
)
DoConversion
(
c
context
.
Context
,
req
*
pb
.
DoConversionRequest
)
(
resp
*
pb
.
DoConversionResponse
,
err
error
)
{
defer
recoverPanic
()
resp
=
&
pb
.
DoConversionResponse
{}
request
:=
&
service
.
DoConversionRequest
{
ProjectName
:
req
.
ProjectName
,
...
...
@@ -88,6 +96,7 @@ func (doc *DocServiceService) DoConversion(c context.Context, req *pb.DoConversi
// 获取转换结果
func
(
doc
*
DocServiceService
)
GetProjectInfo
(
c
context
.
Context
,
req
*
pb
.
GetProjectRequest
)
(
resp
*
pb
.
GetProjectResponse
,
err
error
)
{
defer
recoverPanic
()
resp
=
&
pb
.
GetProjectResponse
{}
ConversionInfo
:=
&
pb
.
DoConversionInfo
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment