浏览代码

app: do not restart the server if app is closing

Jeffrey Morgan 1 年之前
父节点
当前提交
fe758ca319
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      app/src/index.ts

+ 5 - 2
app/src/index.ts

@@ -95,10 +95,12 @@ function server() {
     logger.error(data.toString().trim())
   })
 
-  proc.on('exit', () => {
+  function restart() {
     logger.info('Restarting the server...')
     server()
-  })
+  }
+
+  proc.on('exit', restart)
 
   proc.on('disconnect', () => {
     logger.info('Server disconnected. Reconnecting...')
@@ -106,6 +108,7 @@ function server() {
   })
 
   process.on('exit', () => {
+    proc.off('exit', restart)
     proc.kill()
   })
 }