feat: add vite dev containers
This commit is contained in:
22
src/app.ts
22
src/app.ts
@@ -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); // 退出进程
|
||||
|
||||
Reference in New Issue
Block a user