Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xpkg
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
屠思豪
xpkg
Commits
e174fe94
提交
e174fe94
authored
10月 29, 2025
作者:
mooncake
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xcron 使用eventbus方式初始化
上级
c33da749
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
11 行增加
和
6 行删除
+11
-6
init_app.go
application/init_app.go
+1
-0
xgin.go
gin/xgin/xgin.go
+0
-3
init.go
xcron/init.go
+10
-3
没有找到文件。
application/init_app.go
浏览文件 @
e174fe94
...
...
@@ -24,6 +24,7 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/app"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
_
"gitlab.wanzhuangkj.com/tush/xpkg/xcron"
)
func
init
()
{
...
...
gin/xgin/xgin.go
浏览文件 @
e174fe94
...
...
@@ -24,7 +24,6 @@ import (
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/text"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/validator"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron"
"gitlab.wanzhuangkj.com/tush/xpkg/xutils/weblogutils"
)
...
...
@@ -142,7 +141,5 @@ func New() *gin.Engine {
global
.
G
.
Engine
=
r
xcron
.
Init
()
return
r
}
xcron/init.go
浏览文件 @
e174fe94
package
xcron
import
(
"context"
"github.com/jinzhu/copier"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/gin/engine"
"gitlab.wanzhuangkj.com/tush/xpkg/global"
"gitlab.wanzhuangkj.com/tush/xpkg/pkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/cache"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/dao"
)
func
init
()
{
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicCronInit
,
func
(
ctx
context
.
Context
)
{
Init
()
})
}
func
Init
()
{
initXCron
()
initLocalCron
()
...
...
@@ -17,9 +26,7 @@ func Init() {
func
initLocalCron
()
{
var
cron
config
.
Cron
contextPath
:=
""
config
.
Read
(
func
(
c
*
config
.
Config
)
{
contextPath
=
c
.
App
.
ContextPath
_
=
copier
.
Copy
(
&
cron
,
c
.
Cron
)
})
if
!
cron
.
Enable
{
...
...
@@ -36,6 +43,6 @@ func initLocalCron() {
initCron
()
g
:=
global
.
G
.
Engine
if
g
!=
nil
{
engine
.
RegisterRouters
(
g
,
contextPath
+
"/internal"
,
CronRouterApis
)
engine
.
RegisterRouters
(
g
,
"/internal"
,
CronRouterApis
)
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论