feat: add vite dev containers

This commit is contained in:
2024-10-21 01:36:34 +08:00
parent 644539b624
commit c832c0274a
12 changed files with 590 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
import { App } from '@kevisual/router';
import fs from 'fs';
import { getConfig, pidFilePath, checkFileExists } from './module/get-config.ts';
import { getConfig, getPidList, pidFilePath, checkFileExists } from './module/get-config.ts';
import { sequelize } from './module/sequelize.ts';
export { sequelize };
@@ -28,11 +28,21 @@ app
// 处理进程退出或中断信号,确保删除 pid 文件
const cleanUp = () => {
if (checkFileExists(pidFilePath)) {
const pid = fs.readFileSync(pidFilePath, 'utf-8');
if (Number(pid) === process.pid) {
fs.unlinkSync(pidFilePath);
console.log('server id', process.pid, 'is exit');
const pidList = getPidList();
const findPid = pidList.find((item) => Number(item.pid) === process.pid);
// if (checkFileExists(pidFilePath)) {
// const pid = fs.readFileSync(pidFilePath, 'utf-8');
// if (Number(pid) === process.pid) {
// fs.unlinkSync(pidFilePath);
// console.log('server id', process.pid, 'is exit');
// }
// }
if (findPid) {
console.log('server id', process.pid, 'is exit');
try {
fs.unlinkSync(findPid.file);
} catch (e) {
console.log('unlinkSync error', findPid);
}
}
process.exit(0); // 退出进程