We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac7d6f0 commit 2de0f1aCopy full SHA for 2de0f1a
index.js
@@ -213,6 +213,20 @@ export default async function handler(req, res) {
213
const currentFile = path.normalize(fileURLToPath(import.meta.url)); // 使用 normalize 确保路径一致
214
const indexFile = path.normalize(path.resolve(__dirname, 'index.js')); // 标准化路径
215
216
+// 保证 PM2 restart / stop 一定会触发
217
+['SIGINT', 'SIGTERM', 'SIGUSR2'].forEach(sig =>
218
+ process.on(sig, async () => {
219
+ console.log(`[${sig}] 开始优雅关闭...`);
220
+ try {
221
+ await daemon.stopDaemon();
222
+ console.log('Python 守护进程已停止');
223
+ } catch (e) {
224
+ console.error(e);
225
+ }
226
+ process.exit(0);
227
+ })
228
+);
229
+
230
if (currentFile === indexFile) {
231
start();
232
}
0 commit comments