- 代理层级默认授信比例与停用冻结/禁登全局默认 - 结算预览去重、比分校验、串关当场判负与市场类型校验 - 站内信 Banner/公告自动通知开关;开发环境动态 API 端口 - 扩充 RBAC/结算/认证/返现单元测试与 agent skills
41 lines
1004 B
JavaScript
41 lines
1004 B
JavaScript
import { execSync } from 'node:child_process';
|
|
import { resolveDevApiPort } from './resolve-dev-api-target.mjs';
|
|
|
|
const port = process.argv[2] ?? resolveDevApiPort();
|
|
|
|
function killWindows(portNum) {
|
|
let out = '';
|
|
try {
|
|
out = execSync(`netstat -ano | findstr :${portNum}`, { encoding: 'utf8' });
|
|
} catch {
|
|
return;
|
|
}
|
|
|
|
const pids = new Set();
|
|
for (const line of out.split('\n')) {
|
|
if (!line.includes('LISTENING')) continue;
|
|
const pid = line.trim().split(/\s+/).at(-1);
|
|
if (pid && pid !== '0') pids.add(pid);
|
|
}
|
|
|
|
for (const pid of pids) {
|
|
try {
|
|
console.log(`[ensure-port-free] freeing :${portNum} (PID ${pid})`);
|
|
execSync(`taskkill /F /PID ${pid}`, { stdio: 'ignore' });
|
|
} catch {
|
|
// already gone
|
|
}
|
|
}
|
|
}
|
|
|
|
function killUnix(portNum) {
|
|
try {
|
|
execSync(`lsof -ti tcp:${portNum} | xargs -r kill -9`, { stdio: 'ignore' });
|
|
} catch {
|
|
// port already free
|
|
}
|
|
}
|
|
|
|
if (process.platform === 'win32') killWindows(port);
|
|
else killUnix(port);
|