@tina_summer/codepocket 2.5.8 → 2.6.0
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/bin/codepocket.js +33 -4
- package/package.json +5 -5
package/bin/codepocket.js
CHANGED
|
@@ -254,13 +254,42 @@ function checkRunning() {
|
|
|
254
254
|
if (args[0] === 'stop') {
|
|
255
255
|
const pid = checkRunning()
|
|
256
256
|
if (!pid) {
|
|
257
|
-
|
|
257
|
+
// Even with no recorded daemon PID, clean up orphaned hub/runner from prior runs
|
|
258
|
+
const orphans = killOrphans()
|
|
259
|
+
console.log(orphans
|
|
260
|
+
? `[codepocket] 清理残留进程: ${orphans}`
|
|
261
|
+
: '[codepocket] Not running')
|
|
258
262
|
process.exit(0)
|
|
259
263
|
}
|
|
260
|
-
|
|
264
|
+
const sig = process.platform === 'win32' ? 'SIGKILL' : 'SIGTERM'
|
|
265
|
+
// Kill the whole process group (daemon is a group leader via detached:true,
|
|
266
|
+
// so -pid kills daemon + hub + runner together)
|
|
267
|
+
try { process.kill(-pid, sig) } catch {}
|
|
268
|
+
// Fallback: kill just the daemon if group kill failed
|
|
269
|
+
try { process.kill(pid, sig) } catch {}
|
|
261
270
|
try { fs.unlinkSync(PID_FILE) } catch {}
|
|
262
|
-
|
|
263
|
-
|
|
271
|
+
// Wait briefly, then sweep up any orphans that escaped the group kill
|
|
272
|
+
setTimeout(() => {
|
|
273
|
+
const orphans = killOrphans()
|
|
274
|
+
const extra = orphans ? `,清理残留: ${orphans}` : ''
|
|
275
|
+
console.log(`[codepocket] Stopped (PID ${pid})${extra}`)
|
|
276
|
+
process.exit(0)
|
|
277
|
+
}, 300)
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// Kill orphaned hub/runner processes by binary name (cross-platform).
|
|
281
|
+
// The hub binary (cpkt-hub) also runs the runner/sync modes, so matching the
|
|
282
|
+
// binary name catches every mode it was spawned in.
|
|
283
|
+
function killOrphans() {
|
|
284
|
+
try {
|
|
285
|
+
if (process.platform === 'win32') {
|
|
286
|
+
execSync('taskkill /F /IM cpkt-hub.exe /T', { stdio: 'ignore' })
|
|
287
|
+
} else {
|
|
288
|
+
execSync('pkill -f cpkt-hub', { stdio: 'ignore' })
|
|
289
|
+
}
|
|
290
|
+
return 'hub'
|
|
291
|
+
} catch {}
|
|
292
|
+
return ''
|
|
264
293
|
}
|
|
265
294
|
|
|
266
295
|
// 'logs' subcommand
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tina_summer/codepocket",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "CodePocket — 基于ClaudeCode的微信小程序工作台",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codepocket": "bin/codepocket.js",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"ws": "^8.18.0"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@tina_summer/codepocket-darwin-arm64": "2.
|
|
23
|
-
"@tina_summer/codepocket-darwin-x64": "2.
|
|
24
|
-
"@tina_summer/codepocket-linux-x64": "2.
|
|
25
|
-
"@tina_summer/codepocket-win32-x64": "2.
|
|
22
|
+
"@tina_summer/codepocket-darwin-arm64": "2.6.0",
|
|
23
|
+
"@tina_summer/codepocket-darwin-x64": "2.6.0",
|
|
24
|
+
"@tina_summer/codepocket-linux-x64": "2.6.0",
|
|
25
|
+
"@tina_summer/codepocket-win32-x64": "2.6.0"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=18"
|