ランダムにテストがコケるのを修正 (#7553)
* Test shutdown * Revert "Test shutdown" This reverts commit85182e7dd1
. * Skip beforeShutdown in test * Wait shutdown in test * Revert "Skip beforeShutdown in test" This reverts commit79c33ab536
. * Revert "Revert "Skip beforeShutdown in test"" This reverts commit3423133a13
.
This commit is contained in:
@@ -5,6 +5,7 @@ const FormData = require('form-data');
|
||||
import * as childProcess from 'child_process';
|
||||
import * as http from 'http';
|
||||
import loadConfig from '../src/config/load';
|
||||
import { SIGKILL } from 'constants';
|
||||
|
||||
export const port = loadConfig().port;
|
||||
|
||||
@@ -145,3 +146,19 @@ export function launchServer(callbackSpawnedProcess: (p: childProcess.ChildProce
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function shutdownServer(p: childProcess.ChildProcess, timeout = 20 * 1000) {
|
||||
return new Promise((res, rej) => {
|
||||
const t = setTimeout(() => {
|
||||
p.kill(SIGKILL);
|
||||
res('force exit');
|
||||
}, timeout);
|
||||
|
||||
p.once('exit', () => {
|
||||
clearTimeout(t);
|
||||
res('exited');
|
||||
});
|
||||
|
||||
p.kill();
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user