feat(admin,api,player): 返水流程优化、账单详情与数据库重置
优化返水预览/确认/作废,新增玩家账变详情与后台一键重置为 seed 数据,并修复 dev 启动时 3000 端口占用。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
39
scripts/ensure-port-free.mjs
Normal file
39
scripts/ensure-port-free.mjs
Normal file
@@ -0,0 +1,39 @@
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
const port = process.argv[2] ?? '3000';
|
||||
|
||||
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);
|
||||
Reference in New Issue
Block a user