AI创作任务必须按短视频脚本创作技能执行(跨环境技能定位~/.workbuddy/skills);/api/run/status ACCEPTED归入done
This commit is contained in:
1 parent
ee2bc92e31
commit
ef98395c61
5 files changed
+189
-5
No files matched your search
@@ -0,0 +1,51 @@
|
||||
/* poll-create-tasks.cjs — 轮询 6 个创作任务状态,全部完成/失败后退出 */
|
||||
const TASKS = [
|
||||
{ videoId: 309, id: 'automation-1788250646656' },
|
||||
{ videoId: 313, id: 'automation-1788250649673' },
|
||||
{ videoId: 315, id: 'automation-1788250652690' },
|
||||
{ videoId: 316, id: 'automation-1788250655707' },
|
||||
{ videoId: 318, id: 'automation-1788250658730' },
|
||||
{ videoId: 320, id: 'automation-1788250661754' },
|
||||
];
|
||||
const API = 'http://localhost:8900/api/run/status?id=';
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
const stateOf = new Map(TASKS.map((t) => [t.videoId, 'queued']));
|
||||
let lastPrint = '';
|
||||
|
||||
async function check() {
|
||||
const snap = [];
|
||||
for (const t of TASKS) {
|
||||
try {
|
||||
const r = await fetch(API + encodeURIComponent(t.id));
|
||||
const d = await r.json();
|
||||
stateOf.set(t.videoId, d.state || 'unknown');
|
||||
snap.push(`v${t.videoId}:${d.state || '?'}`);
|
||||
} catch (e) {
|
||||
snap.push(`v${t.videoId}:ERR`);
|
||||
}
|
||||
}
|
||||
const line = snap.join(' ');
|
||||
if (line !== lastPrint) {
|
||||
console.log(new Date().toLocaleTimeString('zh-CN', { hour12: false }) + ' | ' + line);
|
||||
lastPrint = line;
|
||||
}
|
||||
const vals = [...stateOf.values()];
|
||||
const done = vals.filter((s) => ['done', 'error', 'notfound'].includes(s)).length;
|
||||
return done;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
console.log('START polling 6 create tasks: ' + new Date().toLocaleTimeString('zh-CN', { hour12: false }));
|
||||
const t0 = Date.now();
|
||||
while (Date.now() - t0 < 3 * 60 * 60 * 1000) { // 最长 3 小时
|
||||
const done = await check();
|
||||
if (done >= TASKS.length) {
|
||||
console.log('\nALL DONE: ' + [...stateOf.entries()].map(([v, s]) => `v${v}=${s}`).join(' '));
|
||||
process.exit(0);
|
||||
}
|
||||
await sleep(30000);
|
||||
}
|
||||
console.log('\nTIMEOUT 3h, current: ' + [...stateOf.entries()].map(([v, s]) => `v${v}=${s}`).join(' '));
|
||||
process.exit(1);
|
||||
})();
|
||||
Reference in new issue
Block a user