@kevlns/art-workshop 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tasks.mjs CHANGED
@@ -348,13 +348,22 @@ export async function shutdown(settings, { closeServices = true } = {}) {
348
348
  )
349
349
  await sleep(50);
350
350
  // Never close the service while a live art worker is still using it.
351
- if (
352
- tasks(root).some(
353
- (t) =>
354
- !executionSettled(taskStatus(root, t.taskId)) || workerAlive(t),
355
- )
356
- )
357
- throw new Error("任务尚未停止,保留服务:" + failures.join("; "));
351
+ const blockers = tasks(root).filter(
352
+ (t) =>
353
+ !executionSettled(taskStatus(root, t.taskId)) || workerAlive(t),
354
+ );
355
+ if (blockers.length)
356
+ throw new Error(
357
+ "任务尚未停止,保留服务:" +
358
+ (failures.length
359
+ ? failures.join("; ")
360
+ : blockers
361
+ .map(
362
+ (t) =>
363
+ t.taskId + "(status=" + t.status + ", pid=" + t.workerPid + ")",
364
+ )
365
+ .join("; ")),
366
+ );
358
367
  if (failures.length)
359
368
  throw new Error("任务停止尚未确认,保留服务:" + failures.join("; "));
360
369
  if (!closeServices)
@@ -6,7 +6,9 @@ import {hash} from './shared.mjs';
6
6
  export function workerAlive(task, inspect = processIdentity) {
7
7
  const pid = task.workerPid;
8
8
  if (!Number.isSafeInteger(pid) || pid <= 0) return false;
9
- try { process.kill(pid, 0); } catch (error) { return error.code !== 'ESRCH'; }
9
+ // ESRCH:PID 已消失。其余错误(Windows 的 EPERM/EACCES)只说明该 PID 存在
10
+ // 但不归我们管,通常是 PID 被复用;交给下面的身份比对判定。
11
+ try { process.kill(pid, 0); } catch (error) { if (error.code === 'ESRCH') return false; }
10
12
  const current = inspect(pid);
11
13
  if (!current) return true;
12
14
  if (task.workerIdentity) return hash(current) === hash(task.workerIdentity);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevlns/art-workshop",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "description": "管理项目风格、参考图、图片生成、编辑和定版。支持本地 ComfyUI 与远程图片模型。",
6
6
  "type": "module",