File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,18 @@ fastify.addHook('onReady', async () => {
4747 }
4848} ) ;
4949
50- // 停止时清理守护进程
51- fastify . addHook ( 'onClose' , async ( ) => {
50+ async function onClose ( ) {
5251 try {
5352 await daemon . stopDaemon ( ) ;
5453 fastify . log . info ( 'Python守护进程已停止' ) ;
5554 } catch ( error ) {
5655 fastify . log . error ( `停止Python守护进程失败: ${ error . message } ` ) ;
5756 }
57+ }
58+
59+ // 停止时清理守护进程
60+ fastify . addHook ( 'onClose' , async ( ) => {
61+ await onClose ( ) ;
5862} ) ;
5963
6064// 给静态目录插件中心挂载basic验证
@@ -100,7 +104,7 @@ const handleExit = async (signal) => {
100104 try {
101105 console . log ( `\nReceived ${ signal } , closing server...` ) ;
102106 // Fastify 提供的关闭方法,内部会触发 onClose 钩子
103- await stop ( ) ;
107+ await onClose ( ) ;
104108 console . log ( 'Fastify closed successfully' ) ;
105109 process . exit ( 0 ) ;
106110 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments