diff --git a/CHANGELOG.md b/CHANGELOG.md index 38eed283..c78bc791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - YAML support for apps declarations - Improve app declaration file parsing (log_file, out_file, error_file) +# 0.12.11 (Coming next) + +- VersioningManagment: exec() timeout configurable via .json + # 0.12.10 (Current Stable) - Fix : PM2 interactor doesn't send data about dead processes ('_old_') anymore. diff --git a/doc/PULL.md b/doc/PULL.md index 3251cff0..a7bb6306 100644 --- a/doc/PULL.md +++ b/doc/PULL.md @@ -36,6 +36,8 @@ or to the optional specified commit ID. Everytime a backward/pull/forward command is executed, pm2 checks in ecosystem.json, process.json and package.json (in that order) for commands to run (e.g. npm install). The field should be named post_update and should be an array of commands. +You can also set the timeout for exec() command with 'exec_timeout' field (in ms). +By default it is 60000 (60sec). Your file should look something like this : ```json @@ -50,7 +52,8 @@ Your file should look something like this : "script" : "app.js", "post_update" : ["echo App has been updated, running npm install...", "npm install", - "echo App is being restarted now"] + "echo App is being restarted now"], + "exec_timeout" : 30000 } ] } diff --git a/lib/tools/VersionManagement.js b/lib/tools/VersionManagement.js index f7bd8255..1e1f5cd8 100644 --- a/lib/tools/VersionManagement.js +++ b/lib/tools/VersionManagement.js @@ -8,11 +8,12 @@ var CLI = require('../CLI.js'); var Common = require('../Common.js'); var cst = require('../../constants.js'); - var exitCli = Common.exitCli; var printError = Common.printError; var printOut = Common.printOut; +var EXEC_TIMEOUT = 60000; // Default: 1 min + var Methods = {}; /** @@ -251,7 +252,8 @@ Methods.forward = function(process_name, cb) { var exec = function (cmd, callback) { var output = ''; - var c = child.exec(cmd, {env: process.env, maxBuffer: 20*1024*1024, timeout: 30000}, function(err) { + var c = child.exec(cmd, {env: process.env, maxBuffer: 3*1024*1024, timeout: EXEC_TIMEOUT}, + function(err) { if (callback) callback(err ? err.code : 0, output); }); @@ -316,6 +318,8 @@ var getPostUpdateCmds = function(repo_path, proc_name, cb) { async.eachSeries(data.apps, function(item, callb) { if (item.name && item.name === proc_name) { if (item.post_update && typeof(item.post_update) === 'object') { + if (item.exec_timeout) + EXEC_TIMEOUT = parseInt(item.exec_timeout); return callb(item.post_update); } else {