refactor: engine instance listeners

This commit is contained in:
Dr_rOot
2020-05-14 22:21:57 +08:00
parent dba4bfb0e7
commit 7ee8d4fa0f
+4 -1
View File
@@ -63,7 +63,7 @@ export default class Engine {
const sh = this.getStartSh()
logger.info('[Motrix] Engine start sh:', sh)
this.instance = forever.start(sh, {
max: is.dev() ? 1 : 100,
max: is.dev() ? 0 : 100,
parser: function (command, args) {
return {
command: command,
@@ -118,6 +118,9 @@ export default class Engine {
logger.error('[Motrix] Engine stop fail:', err.message)
this.forceStop(pid)
} finally {
this.instance.removeAllListeners('start')
this.instance.removeAllListeners('error')
this.instance.removeAllListeners('stop')
}
}