C端改造

This commit is contained in:
2025-12-10 18:47:17 +08:00
parent 5708afb816
commit 4c477ae22a
61 changed files with 259 additions and 135 deletions

View File

@@ -300,6 +300,7 @@ default-character-set=utf8mb4
// 如果还没退出,强制杀死
this.log('warn', '优雅关闭超时,强制终止...');
this.mysqlProcess.kill('SIGTERM');
await this.sleep(1000);
}
this.log('success', 'MySQL 进程已关闭');
@@ -309,16 +310,30 @@ default-character-set=utf8mb4
if (this.mysqlProcess) {
this.mysqlProcess.kill('SIGTERM');
await this.sleep(1000);
}
// 确保进程被杀死
try {
await this.execCommand('taskkill /F /IM mysqld.exe');
await this.sleep(2000); // 等待文件句柄释放
} catch (e) {
// 忽略
}
}
// 最终检查:确保所有 mysqld.exe 进程都被终止
try {
const { stdout } = await this.execCommand('tasklist /FI "IMAGENAME eq mysqld.exe" /FO CSV /NH');
if (stdout.includes('mysqld.exe')) {
this.log('warn', '检测到残留进程,强制清理...');
await this.execCommand('taskkill /F /IM mysqld.exe');
await this.sleep(2000); // 额外等待以确保文件句柄释放
}
} catch (e) {
// 忽略
}
this.mysqlProcess = null;
this.currentPort = null;
}