mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
fix(dev): clean up web backend lifecycle
This commit is contained in:
1 parent
296573ed5c
commit
953471a514
6 files changed
+124
-106
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { createChatlabStartCommand } from './dev-server-command.mjs'
|
||||
import { createChatlabStartCommand, terminateChatlabStartProcess } from './dev-server-command.mjs'
|
||||
|
||||
test('web dev backend runs through the current Node executable with the tsx loader', () => {
|
||||
const command = createChatlabStartCommand({
|
||||
@@ -25,4 +25,28 @@ test('web dev backend runs through the current Node executable with the tsx load
|
||||
'--port',
|
||||
'3110',
|
||||
])
|
||||
assert.equal(command.options.detached, true)
|
||||
})
|
||||
|
||||
test('web dev backend cleanup terminates the whole POSIX process group', () => {
|
||||
const killed = []
|
||||
const proc = {
|
||||
pid: 12345,
|
||||
exitCode: null,
|
||||
signalCode: null,
|
||||
kill(signal) {
|
||||
killed.push(['child', signal])
|
||||
return true
|
||||
},
|
||||
}
|
||||
|
||||
terminateChatlabStartProcess(proc, {
|
||||
platform: 'darwin',
|
||||
killProcess: (pid, signal) => {
|
||||
killed.push(['process', pid, signal])
|
||||
return true
|
||||
},
|
||||
})
|
||||
|
||||
assert.deepEqual(killed, [['process', -12345, 'SIGTERM']])
|
||||
})
|
||||
Reference in new issue
Block a user