cd auto-workflow-pro
npm install
{
"name": "daily-report",
"trigger": { "type": "cron", "expr": "0 9 * * *" },
"tasks": [
{ "type": "http", "url": "https://api.example.com/data", "save": "temp.json" },
{ "type": "transform", "input": "temp.json", "output": "report.json" },
{ "type": "email", "to": "user@example.com", "subject": "日报", "attach": "report.json" }
]
}
# 立即执行
node workflow.js --run daily-report
# 守护进程模式(监听触发)
node workflow.js --daemon
# 查看任务状态
node workflow.js --status
| 场景 | 触发 | 任务链 |
|---|---|---|
| ------ | ------ | -------- |
| 每日数据同步 | cron 0 2 * | API获取 → 清洗 → 存库 |
| 新文件处理 | 文件监控 | 检测新文件 → 转换 → 通知 |
| 异常报警 | webhook | 检查服务 → 告警 → 记录 |
http: HTTP请求transform: 数据转换email: 发送邮件webhook: 回调通知file: 文件操作database: 数据库操作sleep: 延迟等待共 1 个版本