ランダムにテストがコケるのを修正 (#7553)

* Test shutdown

* Revert "Test shutdown"

This reverts commit 85182e7dd196cdd9ecb46cfb50adaabd04c5ba60.

* Skip beforeShutdown in test

* Wait shutdown in test

* Revert "Skip beforeShutdown in test"

This reverts commit 79c33ab53615e8fa4820d2abfc2494cba55c441c.

* Revert "Revert "Skip beforeShutdown in test""

This reverts commit 3423133a137c79b64f3ff6ef9dbe433a441a47b0.
This commit is contained in:
MeiMei
2021-06-05 14:54:07 +09:00
committed by GitHub
parent a5cdc9a1f4
commit 5d66bb8794
7 changed files with 34 additions and 15 deletions

View File

@ -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();
});
}