mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-03 17:59:24 +02:00
Improve shutdown in the test script
This commit is contained in:
parent
24563bdc4a
commit
21d7fa839f
3 changed files with 10 additions and 4 deletions
|
@ -52,5 +52,4 @@ async function main() {
|
||||||
|
|
||||||
main().catch((ex) => {
|
main().catch((ex) => {
|
||||||
console.warn(ex)
|
console.warn(ex)
|
||||||
process.exit(1)
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -64,7 +64,11 @@ async function startMariadb() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
shutdown: () => task.kill('SIGINT'),
|
shutdown: () => {
|
||||||
|
spawnAsync('mysql', ['-S', socketPath, '-u', 'root', '-e', 'SHUTDOWN;'], { stdio: 'inherit' }).catch((ex) => {
|
||||||
|
console.warn(ex)
|
||||||
|
})
|
||||||
|
},
|
||||||
socketPath,
|
socketPath,
|
||||||
dataDir,
|
dataDir,
|
||||||
database,
|
database,
|
||||||
|
|
|
@ -16,12 +16,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const { spawn } = require('child_process')
|
const { spawn } = require('child_process')
|
||||||
|
const { resolve } = require('path')
|
||||||
|
|
||||||
function startMainApp(env) {
|
function startMainApp(env) {
|
||||||
|
const initPath = resolve(__dirname, '../../build/index.js')
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const task = spawn('npm', ['start'], {
|
const task = spawn('node', [initPath], {
|
||||||
stdio: ['inherit', 'pipe', 'inherit'],
|
stdio: ['inherit', 'pipe', 'inherit'],
|
||||||
env: { ...process.env, PORT: 0 /* random port */, ...env }
|
env: { ...process.env, PORT: 0 /* random port */ }
|
||||||
})
|
})
|
||||||
|
|
||||||
task.on('exit', () => reject(new Error('task terminated too early')))
|
task.on('exit', () => reject(new Error('task terminated too early')))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue