mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 00:28:42 +00:00
test(e2e): isolate kitchen sink rpc gateway
This commit is contained in:
@@ -25,6 +25,7 @@ const COMMAND_TIMEOUT_MS = readPositiveInt(
|
||||
);
|
||||
const RPC_TIMEOUT_MS = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_CALL_MS, 60000);
|
||||
const MAX_RSS_MIB = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_MAX_RSS_MIB, 2048);
|
||||
const DEFAULT_PORT = 19000 + Math.floor(Math.random() * 1000);
|
||||
|
||||
let callGatewayModulePromise;
|
||||
|
||||
@@ -357,7 +358,7 @@ function startGateway(runner, port, env, logPath) {
|
||||
const child = childProcess.spawn(command.command, command.args, {
|
||||
...command.options,
|
||||
env,
|
||||
detached: false,
|
||||
detached: process.platform !== "win32",
|
||||
});
|
||||
fs.closeSync(log);
|
||||
return child;
|
||||
@@ -367,16 +368,26 @@ async function stopGateway(child) {
|
||||
if (!child || child.exitCode !== null) {
|
||||
return;
|
||||
}
|
||||
child.kill("SIGTERM");
|
||||
signalGateway(child, "SIGTERM");
|
||||
const started = Date.now();
|
||||
while (child.exitCode === null && Date.now() - started < 10000) {
|
||||
await delay(100);
|
||||
}
|
||||
if (child.exitCode === null) {
|
||||
child.kill("SIGKILL");
|
||||
signalGateway(child, "SIGKILL");
|
||||
}
|
||||
}
|
||||
|
||||
function signalGateway(child, signal) {
|
||||
if (process.platform !== "win32" && typeof child.pid === "number") {
|
||||
try {
|
||||
process.kill(-child.pid, signal);
|
||||
return;
|
||||
} catch {}
|
||||
}
|
||||
child.kill(signal);
|
||||
}
|
||||
|
||||
async function waitForGatewayReady(child, port, logPath) {
|
||||
const started = Date.now();
|
||||
let lastError = "";
|
||||
@@ -555,7 +566,7 @@ function isNonEmptyString(value) {
|
||||
|
||||
async function main() {
|
||||
const runner = resolveOpenClawRunner();
|
||||
const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, 19173);
|
||||
const port = readPositiveInt(process.env.OPENCLAW_KITCHEN_SINK_RPC_PORT, DEFAULT_PORT);
|
||||
const { root, env } = makeEnv();
|
||||
const logPath = path.join(root, "gateway.log");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user