Socket
Socket
Sign inDemoInstall

pm2

Package Overview
Dependencies
Maintainers
1
Versions
278
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pm2 - npm Package Compare versions

Comparing version 0.6.14 to 0.6.15

test/fixtures/env.js

2

apps/echo-pm2.json

@@ -6,3 +6,3 @@ {

"name" : "ok",
"pidFile" : "echo.pid",
"pid_file" : "echo.pid",
"max" : "1",

@@ -9,0 +9,0 @@ "exec_mode" : "cluster_mode",

@@ -6,3 +6,3 @@ {

"name" : "ok",
"pidFile" : "echo.pid",
"pid_file" : "echo.pid",
"max" : "1",

@@ -9,0 +9,0 @@ "exec_mode" : "cluster_mode",

@@ -22,5 +22,5 @@ //

DAEMON_PUB_PORT : parseInt(process.env.PM2_PUB_PORT) || 6667, // Realtime events
CODE_UNCAUGHTEXCEPTION : 100,
DEBUG : process.env.PM2_DEBUG || false,

@@ -27,0 +27,0 @@ WEB_INTERFACE : parseInt(process.env.PM2_API_PORT) || 9615,

@@ -7,3 +7,3 @@ {

"out_file":"outfile.log",
"pidFile":"pidfile.pid"
"pid_file":"pidfile.pid"
}

@@ -1,1 +0,1 @@

{"script":"child.js","name":"child.js","instances":10,"error_file":"errfile.log","out_file":"outfile.log","pidFile":"pidfile.pid"}
{"script":"child.js","name":"child.js","instances":10,"error_file":"errfile.log","out_file":"outfile.log","pid_file":"pidfile.pid"}

@@ -254,3 +254,2 @@

process.exit(cst.ERROR_EXIT);
return;
}

@@ -262,2 +261,14 @@ speedList();

CLI.reloadProcessName = function (process_name) {
console.log(cst.PREFIX_MSG + 'Reloading process by name %s', process_name);
Satan.executeRemote('reloadProcessName', process_name, function(err) {
if (err) {
console.error('Cannot reload process: ' + err);
process.exit(cst.ERROR_EXIT);
}
speedList();
console.log('\n' + cst.PREFIX_MSG + 'Processes name %s reloaded', process_name);
});
};
CLI.restartProcessByName = function(pm2_name) {

@@ -443,2 +454,32 @@ Satan.executeRemote('restartProcessName', pm2_name, function(err, list) {

CLI.sendSignalToProcessName = function(signal, process_name) {
Satan.executeRemote('sendSignalToProcessName', {
signal : signal,
process_name : process_name
}, function(err, list) {
if (err) {
console.error('Error : ' + err);
process.exit(cst.ERROR_EXIT);
}
console.log(cst.PREFIX_MSG + 'Succesfully sent signal %s to process name %s', signal, process_name);
UX.processing.stop();
speedList();
});
};
CLI.sendSignalToProcessId = function(signal, process_id) {
Satan.executeRemote('sendSignalToProcessId', {
signal : signal,
process_id : process_id
}, function(err, list) {
if (err) {
console.error(err);
process.exit(cst.ERROR_EXIT);
}
console.log(cst.PREFIX_MSG + 'Succesfully sent signal %s to process id %s', signal, process_id);
UX.processing.stop();
speedList();
});
};
CLI.monit = function() {

@@ -488,11 +529,13 @@ Satan.executeRemote('getMonitorData', {}, function(err, list) {

if (((!id || (id && !isNaN(parseInt(id)) && tdb[k].pm2_env.pm_id == id)) ||
(!id || (id && isNaN(parseInt(id)) && tdb[k].name == id))) &&
(!id || (id && isNaN(parseInt(id)) && tdb[k].pm2_env.name == id))) &&
tdb[k].pm2_env.status == cst.ONLINE_STATUS) {
var app_name = tdb[k].pm2_env.name || p.basename(tdb[k].pm2_env.pm_exec_path);
if (tdb[k].pm2_env.pm_out_log_path)
if (tdb[k].pm2_env.pm_out_log_path) {
Log.stream(tdb[k].pm2_env.pm_out_log_path,
app_name + '-' + tdb[k].pm_id + ' (out)');
if (tdb[k].pm2_env.pm_err_log_path)
}
if (tdb[k].pm2_env.pm_err_log_path) {
Log.stream(tdb[k].pm2_env.pm_err_log_path,
app_name + '-' + tdb[k].pm_id + ' (err)');
}
}

@@ -519,2 +562,6 @@ }

function speedList() {
var self = this;
if (!this.retry)
this.retry = 0;
if (commander.silent)

@@ -524,2 +571,7 @@ process.exit(cst.SUCCESS_EXIT);

if (err) {
console.log(self.retry);
if (self.retry == 0) {
self.retry += 1;
return setTimeout(speedList, 500);
}
console.error('Error retrieving process list: ' + err);

@@ -526,0 +578,0 @@ process.exit(cst.ERROR_EXIT);

@@ -34,5 +34,4 @@ /**

app.env = {
pm_cwd: cwd
};
app.env = app.env || {};
app.env.pm_cwd = cwd;

@@ -39,0 +38,0 @@ if (!('exec_mode' in app)) app['exec_mode'] = 'cluster_mode';

@@ -379,2 +379,43 @@ /**

God.reloadProcessName = function(name, cb) {
var workerAmount = 0;
for (var id in God.clusters_db) {
if ((p.basename(God.clusters_db[id].pm2_env.pm_exec_path) == name ||
p.basename(God.clusters_db[id].pm2_env.pm_exec_path) == p.basename(name) ||
God.clusters_db[id].pm2_env.name == name) &&
God.clusters_db[id].pm2_env.exec_mode == 'cluster_mode' &&
God.clusters_db[id].pm2_env.status != cst.STOPPED_STATUS) {
workerAmount++;
(function (oldWorker, currentWorkerIndex) {
executeApp(oldWorker.pm2_env, function(err, newWorker) {
newWorker.once('listening', function(){
console.log("%s - id%d worker listening",
newWorker.pm2_env.pm_exec_path,
newWorker.pm2_env.pm_id);
oldWorker.once('disconnect', function(){
console.log('%s - id%d worker disconnect',
oldWorker.pm2_env.pm_exec_path,
oldWorker.pm2_env.pm_id);
God.stopProcessId(oldWorker.pm2_env.pm_id, function(){
if(currentWorkerIndex === workerAmount){
setTimeout(cb, 2000);
}
});
});
oldWorker.disconnect();
});
});
})(God.clusters_db[id], workerAmount);
}
}
setTimeout(function() {
if (workerAmount == 0)
return cb(new Error('no process with name ' + name));
}, 4000);
};
God.getProcesses = function() {

@@ -517,2 +558,3 @@ return God.clusters_db;

/**

@@ -554,2 +596,3 @@ * Stop a process and set it on state "stopped"

};
/**

@@ -647,2 +690,61 @@ * Restart a process ID

/**
* Send system signal to process id
* @param {integer} Id pm2 process id
* @param {string} signal signal type
*/
God.sendSignalToProcessId = function(opts, cb) {
var id = opts.process_id;
var signal = opts.signal;
if (!(id in God.clusters_db))
return cb(new Error({msg : "PM ID unknown"}), {});
var proc = God.clusters_db[id];
try {
process.kill(God.clusters_db[id].process.pid, signal);
} catch(e) {
console.error(e);
return cb(new Error('Error when sending signal (signal unknown)'));
}
return cb(null, God.getFormatedProcesses());
};
/**
* Send system signal to all processes by name
* @param {integer} name pm2 process name
* @param {string} signal signal type
*/
God.sendSignalToProcessName = function(opts, cb) {
var name = opts.process_name;
var signal = opts.signal;
var arr = Object.keys(God.clusters_db);
(function ex(arr) {
if (arr[0] == null) {
return cb(null, God.getFormatedProcesses());
}
var key = arr[0];
if ((p.basename(God.clusters_db[key].pm2_env.pm_exec_path) == name ||
p.basename(God.clusters_db[key].pm2_env.pm_exec_path) == p.basename(name) ||
God.clusters_db[key].pm2_env.name == name) &&
God.clusters_db[key].pm2_env.status != cst.STOPPED_STATUS) {
try {
process.kill(God.clusters_db[key].process.pid, signal);
} catch(e) {
console.error(e);
}
arr.shift();
return ex(arr);
}
else {
arr.shift();
return ex(arr);
}
return false;
})(arr);
};
/**
* Delete a process by name

@@ -674,3 +776,2 @@ * It will stop it and remove it from the database

/**

@@ -677,0 +778,0 @@ * Delete all processes

@@ -118,2 +118,3 @@

reload : God.reload,
reloadProcessName : God.reloadProcessName,
killMe : God.killMe,

@@ -128,3 +129,5 @@ findByScript : God.findByScript,

msgProcess : God.msgProcess,
deleteAll : God.deleteAll
deleteAll : God.deleteAll,
sendSignalToProcessId : God.sendSignalToProcessId,
sendSignalToProcessName : God.sendSignalToProcessName
});

@@ -131,0 +134,0 @@

{
"name": "pm2",
"preferGlobal": "true",
"version": "0.6.14",
"version": "0.6.15",
"engines" : {

@@ -36,3 +36,3 @@ "node" : ">=0.8"

"scripts": {
"test": "bash ./test/cli.sh && bash ./test/cli2.sh && bash ./test/fork.sh && bash ./test/infinite_loop.sh && NODE_ENV=test ./node_modules/mocha/bin/mocha test"
"test": "bash ./test/cli.sh && bash ./test/cli2.sh && bash ./test/misc.sh && bash ./test/signal.sh && bash ./test/fork.sh && bash ./test/infinite_loop.sh && NODE_ENV=test ./node_modules/mocha/bin/mocha test"
},

@@ -39,0 +39,0 @@ "keywords": [

@@ -13,3 +13,3 @@ # ![Monit](https://github.com/unitech/pm2/raw/master/pres/top-logo-wo.png)

- Script daemonization
- 0s downtime reload
- 0s downtime reload for Node
- Startup scripts for Ubuntu and CentOS

@@ -31,2 +31,15 @@ - Stop unstable process (avoid infinite loop)

# Monitoring dashboard
![Dashboard](http://leapfrogui.com/controlfrog/img/cf-layout-1.png)
We gonna release a very nice product, a dashboard to monitor every part of your NodeJS applications. Here are some links :
- [Pitch + Survey](https://docs.google.com/forms/d/1FuCjIhrGg-ItxInq2nLreoe9GS-gZWJNkNWE0JJajw8/viewform) People who fill the survey will be elligible for free license
- [Newsletter](http://signup.pm2.io/) Subscribe to be kept informed
We are also looking for AngularJS developers and designers contact us at contact AT unitech DOT io
Thanks in advance and we hope that you like pm2 !
# Readme Contents

@@ -132,13 +145,2 @@

<a name="a32"/>
## Install on fresh server
Ubuntu
```bash
$ sudo apt-get install build-essential git htop curl
$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
$ nvm install v0.11.9
```
<a name="a16"/>

@@ -151,7 +153,7 @@ ## 0s downtime reload

- Only for networked app
- Running on Node 0.11.x
- In cluster mode (default mode)
- Only for app in cluster mode (default mode)
```bash
$ pm2 reload all
$ pm2 reload my-api
```

@@ -210,3 +212,13 @@

If a test is broken please report us issues [here](https://github.com/Unitech/pm2/issues?state=open)
Also make sure you have all dependencies needed. For Ubuntu :
```bash
$ sudo apt-get install build-essential
$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
$ nvm install v0.11.9
$ nvm use v0.11.9
$ nvm alias default v0.11.9
```
<a name="a6"/>

@@ -285,4 +297,8 @@ ## pm2 list

"args" : "['--toto=heya coco', '-d', '1']",
"exec_mode" : "fork_mode"
},{
"env": {
"NODE_ENV": "production",
"AWESOME_SERVICE_API_TOKEN": "xxx"
}
}
,{
"name" : "api",

@@ -293,2 +309,3 @@ "script" : "./examples/child.js",

"out_file" : "./examples/child-out.log",
"pid_file" : "./examples/child.pid",
"exec_mode" : "cluster_mode",

@@ -300,2 +317,3 @@ "port" : 9005

"name" : "auto-kill",
"exec_mode" : "fork_mode",
"script" : "./examples/killfast.js"

@@ -302,0 +320,0 @@ }]

@@ -29,2 +29,4 @@

God.should.have.property('stopProcessId');
God.should.have.property('sendSignalToProcessId');
God.should.have.property('sendSignalToProcessName');
});

@@ -48,8 +50,8 @@

});
});
});
});
describe('One process', function() {
var proc, pid;
afterEach(function(done) {

@@ -72,3 +74,3 @@ God.deleteAll({}, done);

var clu, pid;
it('should start a process', function(done) {

@@ -118,3 +120,3 @@ God.prepare(getConf(), function(err, proce) {

});
it('should stop and delete a process id', function(done) {

@@ -181,3 +183,3 @@ var old_pid = clu.process.pid;

it('should start maximum processes depending on CPU numbers', function(done) {
it('should start maximum processes depending on CPU numbers', function(done) {
God.prepare({

@@ -212,3 +214,3 @@ pm_exec_path : path.resolve(process.cwd(), 'test/fixtures/echo.js'),

});
});

@@ -215,0 +217,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc