From 59e000249d7e46c89a2b541decb3cc3525f686c0 Mon Sep 17 00:00:00 2001 From: Tjatse Date: Thu, 17 Dec 2015 19:04:02 +0800 Subject: [PATCH] auto-fallback --- lib/mon.js | 16 +++++++++++++--- pm2-gui.ini | 10 ++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/mon.js b/lib/mon.js index fe13fa2..71c58fe 100644 --- a/lib/mon.js +++ b/lib/mon.js @@ -71,10 +71,20 @@ Monitor.prototype._init = function (options) { } catch (err) { console.error('Can not load PM2 config, the file "' + pm2ConfPath + '" does not exist.'); options.pm2Conf = { - DAEMON_RPC_PORT: defConf.pm2.rpc, - DAEMON_PUB_PORT: defConf.pm2.pub, - INTERACTOR_RPC_PORT: defConf.pm2.interactor_rpc + DAEMON_RPC_PORT: path.resolve(options.pm2, 'rpc.sock'), + DAEMON_PUB_PORT: path.resolve(options.pm2, 'pub.sock'), + PM2_LOG_FILE_PATH: path.resolve(options.pm2, 'pm2.log') }; + + if (!fs.existsSync(options.pm2Conf.DAEMON_RPC_PORT)) { + throw new Error(fbMsg + ' But file ' + options.pm2Conf.DAEMON_RPC_PORT + ' can not found.'); + } + if (!fs.existsSync(options.pm2Conf.DAEMON_PUB_PORT)) { + throw new Error(fbMsg + ' But file ' + options.pm2Conf.DAEMON_PUB_PORT + ' can not found.'); + } + if (!fs.existsSync(options.pm2Conf.PM2_LOG_FILE_PATH)) { + throw new Error(fbMsg + ' But file ' + options.pm2Conf.PM2_LOG_FILE_PATH + ' can not found.'); + } } // Bind socket.io server to context. diff --git a/pm2-gui.ini b/pm2-gui.ini index d2e8ffd..642d6cd 100644 --- a/pm2-gui.ini +++ b/pm2-gui.ini @@ -1,10 +1,4 @@ refresh = 5000 +pm2 = ~/.pm2 debug = true -port = 8088 - -; Overidde PM2 configuration if defined -[pm2] -home = ~/.pm2 -;rpc = ~/.pm2/rpc.sock -;pub = ~/.pm2/pub.sock -;interactor_rpc = ~/.pm2/interactor.sock \ No newline at end of file +port = 8088 \ No newline at end of file