fixed ENOMEM crashing PM2

This commit is contained in:
jshkurti 2015-06-05 17:50:30 +02:00
parent fb928131af
commit 30d03dc6d4
2 changed files with 20 additions and 13 deletions

View File

@ -627,7 +627,6 @@ Satan.unlock = function(opts, cb) {
if (require.main === module) {
var pkg = require('../package.json');
var God = require('./God.js');
process.title = 'PM2 v' + pkg.version + ': God Daemon';
@ -639,18 +638,13 @@ if (require.main === module) {
d.once('error', function(err) {
console.error('[PM2] Error caught by domain:\n' + (err.stack || err));
console.error('[PM2] Trying to update PM2...');
process.once('uncaughtException', function() {
console.error('[PM2] Automatic `pm2 update` failed. Killing PM2 daemon and its processes...');
process.emit('SIGTERM');
require('child_process').spawn('node', [process.env['_'], 'update'], {
detached: true,
stdio: 'inherit'
});
God.dumpProcessList(function() {
require('child_process').spawn('node', [process.env['_'], 'update'], {
detached: true,
stdio: [0,1,2]
});
});
});
d.run(function() {

View File

@ -2,7 +2,7 @@ var vizion = require('vizion');
var cst = require('../constants.js');
var async = require('async');
var debug = require('debug')('pm2:worker');
var domain = require('domain');
module.exports = function(God) {
var timer = null;
@ -57,7 +57,6 @@ module.exports = function(God) {
var versioningRefresh = function(proc_key, cb) {
var proc = _getProcessById(proc_key.pm2_env.pm_id);
if (!(proc &&
proc.pm2_env &&
proc.pm2_env.vizion !== false &&
@ -135,9 +134,23 @@ module.exports = function(God) {
});
};
var wrappedTasks = function() {
var d = domain.create();
d.once('error', function(err) {
console.error('[PM2][WORKER] Error caught by domain:\n' + (err.stack || err));
God.Worker.is_running = false;
});
d.run(function() {
tasks();
});
};
God.Worker.start = function() {
console.log('[PM2][WORKER] Started with refreshing interval: '+cst.WORKER_INTERVAL);
timer = setInterval(tasks, cst.WORKER_INTERVAL);
timer = setInterval(wrappedTasks, cst.WORKER_INTERVAL);
};
God.Worker.stop = function() {