mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 22:46:38 +08:00
fix(task): execute dispatched jobs and persist run records
Asynq func handlers now go through ProcessTask so admin execution rows leave pending. The in-process worker resolves admin type identifiers and writes the same w_task_executions table. Remove the no-op admin system_cleanup that shadowed the upload handler.
This commit is contained in:
@@ -181,22 +181,7 @@ func (p *Plugin) Apply(ctx *core.Context) error {
|
||||
return err
|
||||
}, extpoints.WithTaskMeta(service.LogDBSwitchMeta))
|
||||
|
||||
ctx.Task().Register("admin:system_cleanup", func(_ context.Context, _ []byte) error {
|
||||
return nil
|
||||
},
|
||||
extpoints.WithTaskType("system_cleanup"),
|
||||
extpoints.WithTaskName("系统垃圾清理"),
|
||||
extpoints.WithTaskDescription("定期清理未使用上传文件、历史推送记录和过期任务执行日志"),
|
||||
extpoints.WithTaskCategory("maintenance"),
|
||||
extpoints.WithTaskRetry(1),
|
||||
extpoints.WithTaskQueue("default"),
|
||||
extpoints.WithTaskRetryable(true),
|
||||
)
|
||||
|
||||
// 3. Register Cron Schedules
|
||||
ctx.Schedule().RegisterCron("0 4 * * *", "admin:system_cleanup", map[string]string{"type": "daily"})
|
||||
|
||||
// 4. Register Settings Schemas
|
||||
// 3. Register Settings Schemas
|
||||
ctx.Settings().Register(extpoints.SettingSchema{
|
||||
Key: "admin.system_cleanup_cron",
|
||||
Default: "0 4 * * *",
|
||||
|
||||
@@ -33,14 +33,9 @@ func TestAdminPluginUnit(t *testing.T) {
|
||||
assert.True(t, hasRobots, "admin plugin must register /robots.txt")
|
||||
|
||||
// Verify tasks
|
||||
_, ok := ctx.Tasks().Get("admin:system_cleanup")
|
||||
_, ok := ctx.Tasks().Get("logs:db_switch")
|
||||
require.True(t, ok)
|
||||
|
||||
// Verify schedules
|
||||
sched, ok := ctx.Schedules().Get("admin:system_cleanup")
|
||||
require.True(t, ok)
|
||||
assert.Equal(t, "0 4 * * *", sched.Spec)
|
||||
|
||||
// Verify settings
|
||||
setting, ok := ctx.Settings().Get("admin.system_cleanup_cron")
|
||||
require.True(t, ok)
|
||||
|
||||
Reference in New Issue
Block a user