skillmkt 0.4.30 → 0.4.31
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/client/commands/serve.js +8 -2
- package/package.json +1 -1
package/client/commands/serve.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import http from 'node:http';
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
|
-
import { daemonFile, readDaemon } from '../lib/daemon.js';
|
|
6
|
+
import { daemonFile, readDaemon, openURL } from '../lib/daemon.js';
|
|
7
7
|
import { loadConflicts } from '../lib/conflicts.js';
|
|
8
8
|
import { loadDecisions, decide } from '../lib/decide.js';
|
|
9
9
|
import { readLibrary, readLock, readConfig, writeConfig, registerSkill, updateLock, ensureHub, isInitialized } from '../lib/hub.js';
|
|
@@ -213,12 +213,18 @@ export async function run(ctx) {
|
|
|
213
213
|
// 已有前台/分离实例在跑 → 不重复起,报地址
|
|
214
214
|
const existing = readDaemon(ctx.hub);
|
|
215
215
|
if (existing && existing.pid !== process.pid) {
|
|
216
|
-
try {
|
|
216
|
+
try {
|
|
217
|
+
process.kill(existing.pid, 0);
|
|
218
|
+
info(L(`已在跑: http://127.0.0.1:${existing.port}/?token=${existing.token}(--stop 停掉)`, `already running: http://127.0.0.1:${existing.port}/?token=${existing.token} (use --stop to stop)`));
|
|
219
|
+
if (ctx.tty && !flags.daemon) openURL(existing, '/');
|
|
220
|
+
return 0;
|
|
221
|
+
} catch { /* stale */ }
|
|
217
222
|
}
|
|
218
223
|
const d = await startServer(ctx, { quiet: !!flags.daemon, port: flags.port || 0 });
|
|
219
224
|
if (flags.daemon) { console.log(`daemon ready :${d.port}`); await new Promise(() => {}); }
|
|
220
225
|
console.log(`serve: http://127.0.0.1:${d.port}/?token=${d.token}`);
|
|
221
226
|
console.log(L(` 前台运行 — Ctrl-C 退出(idle ${ctx.config.daemon?.idle_minutes ?? 30}m 自退)`, ` running in foreground — Ctrl-C to exit (idle ${ctx.config.daemon?.idle_minutes ?? 30}m auto-stop)`));
|
|
227
|
+
if (ctx.tty) openURL(d, '/'); // TTY 起服务自动开浏览器;脚本/--daemon 不开
|
|
222
228
|
await new Promise(() => {});
|
|
223
229
|
return 0;
|
|
224
230
|
}
|