From 9eaeb0e3a5ce961fc08955a68d43f42c452f7f8f Mon Sep 17 00:00:00 2001 From: sailxjx Date: Tue, 15 Apr 2014 10:54:36 +0800 Subject: [PATCH] fix crash in `pm2 desc id` add default exec_interpreter when startFromJson --- lib/Common.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Common.js b/lib/Common.js index ce710829..fae58e12 100644 --- a/lib/Common.js +++ b/lib/Common.js @@ -8,6 +8,7 @@ var util = require('util'); var cronJob = require('cron').CronJob; var cst = require('../constants.js'); +var extItps = require('./interpreter.json'); var p = path; /** @@ -35,6 +36,15 @@ Common.resolveAppPaths = function(app, cwd, outputter) { app.env = app.env || {}; app.env.pm_cwd = cwd; + if (!app.exec_interpreter) { + if (extItps[path.extname(app.script)]) { + app.exec_interpreter = extItps[path.extname(app.script)]; + app.exec_mode = 'fork_mode'; + } else { + app.exec_interpreter = 'node'; + } + }; + if (!('exec_mode' in app)) app['exec_mode'] = 'cluster_mode'; app["pm_exec_path"] = path.resolve(cwd, app.script); @@ -44,7 +54,6 @@ Common.resolveAppPaths = function(app, cwd, outputter) { app["name"] = p.basename(app["pm_exec_path"]); } - if (fs.existsSync(app.pm_exec_path) == false) { return new Error('script not found : ' + app.pm_exec_path); }