跳到正文
Skillpedia
自动化25k · #10105

nocobase-app-plugin-scheduler

它能做什么

这项技能指导开发者在 NocoBase 3 应用中构建定时任务,并让业务管理员可以看到其状态。适合需要监控周期性工作的团队。

适用场景

  • ✓当业务管理员需要在应用中查看和跟踪周期性任务时。
  • ✓当你想在代码中定义一个计划,并让其状态在界面中可见时。
  • ✓当后台任务不需要界面可见性,你需要选择其他任务机制时。

技能链接

https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-scheduler/skills/nocobase-app-plugin-scheduler/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/nocobase/nocobase/blob/v3-develop/packages/plugins/app-plugin-scheduler/skills/nocobase-app-plugin-scheduler/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我添加一个每晚执行的任务来归档旧订单,并让管理员能查看其运行情况并将其关闭。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会在代码中定义计划及其执行逻辑,注册目标,并报告最终状态。Scheduler 会保存触发历史,方便管理员跟踪每一次运行。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Develop Scheduled Tasks in an Application

Use the installed version's public exports, without importing plugin internals. The application owns business logic, schedule declarations, Providers, permissions, and deployment timing. Scheduler owns scheduling projections, trigger history, and execution state. The plugin's skills/ directory is the source of truth; do not edit the synchronized application copy under .agents/skills/.

Decide Whether to Use Scheduler

The primary reason to define tasks through Scheduler is UI observability for business administrators. Developers define schedules and execution logic in code. Business administrators use the task list and detail pages the application builds on the Scheduler API to view schedules, track individual executions, and enable or disable tasks when authorized.

Tasks that do not need to be viewed and tracked through the UI must not be managed by the Scheduler plugin. Give recurring ones a ScheduleExecutor of their own from the application's jobs service (jobExecutorServiceToken in @nocobase/app-server/jobs), and one-off background work a JobExecutor; the application development Skill describes both. For administrator-visible tasks, deliver Client registration, access permissions, meaningful task names, and accurate final execution status together; successful server-side dispatch alone is incomplete.

Then Choose the Execution Model

After deciding to use Scheduler, choose according to business complexity:

Scenario Choice Implementation boundary
Periodic cleanup, cache refresh, a single report, or one business Service call Own target type Short operations may complete directly; hand lengthy work to a JobExecutor
A simple operation that happens hourly Own target type Cron alone is not a reason to introduce a heavier execution system
Immediate asynchronous execution JobExecutor No Cron Schedule is needed
A one-time delay, such as ten minutes after a request Queue delay No Cron Schedule is needed; JobExecutor has no delay
Another execution system with its own references, status queries, and completion protocol Own target type The same registerTarget() call, with inspect() and completion reporting for work that finishes later

Every schedule points at a registered target; registerTarget() is the target extension surface, and there is no built-in target type. A target does not guarantee exactly-once external business effects; design business idempotency.

Read by Task

Development Loop

  1. Establish which tasks and execution records administrators need to see. Check Server/Client/CLI registration, page permissions, the application's jobs configuration (a redis adapter for more than one instance; memory serves one process) and JobExecutorServiceProvider composition and target availability, then choose or register the target type.
  2. Implement business logic and Providers in application source, and call schedulerServiceToken.defineSchedule(definition) with an application-wide stable key from that Provider's register()/boot().
  3. Validate payload/inpu
常见问题

所有后台任务都应使用 Scheduler 吗?

不应。技能说明,不需要界面可见性的任务不应使用它。

谁可以开启或关闭任务?

获得授权的业务管理员,通过界面操作。

Scheduler 包含业务逻辑吗?

不包含。业务逻辑由应用负责,Scheduler 只负责调度和状态。

详情

作者的原始描述

Develop scheduled tasks in NocoBase 3 that business administrators need to view and track through the application UI. Define schedules in code, register the target a schedule points at, integrate execution status, and report completion. Do not use Scheduler to manage tasks that do not need UI visibility.

repo: nocobase/nocobase

热度

GitHub 星标
25k
排名
#10105
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能