Comparing version 0.5.0 to 0.5.1
@@ -149,3 +149,4 @@ // pm2-monitor // Code name : God | ||
God.stopProcess = function(clu, cb) { | ||
if (!God.clusters_db[clu.pm_id]) return cb(); | ||
if (!God.clusters_db[clu.pm_id]) | ||
return cb(); | ||
if (God.clusters_db[clu.pm_id].status != 'stopped'){ | ||
@@ -165,3 +166,3 @@ process.kill(God.clusters_db[clu.pm_id].process.pid); | ||
setTimeout(function() { | ||
cb(null, null); | ||
cb(null, God.getFormatedProcesses()); | ||
}, 200); | ||
@@ -171,4 +172,26 @@ }; | ||
// | ||
// Public method | ||
// Stop a process by script name (script path basename) | ||
// | ||
God.stopProcessName = function(name, cb) { | ||
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].opts.pm_exec_path) == name) { | ||
God.stopProcessId(key, function() { | ||
arr.shift(); | ||
return ex(arr); | ||
}); | ||
} | ||
else { | ||
arr.shift(); | ||
return ex(arr); | ||
} | ||
})(arr); | ||
}; | ||
// | ||
// Main entrance for script execution | ||
// | ||
God.prepare = function(opts, cb) { | ||
@@ -175,0 +198,0 @@ if (opts.instances) { |
@@ -5,3 +5,3 @@ // pm2-htop | ||
var multimeter = require('multimeter'); | ||
var multimeter = require('pm2-multimeter'); | ||
var os = require('os'); | ||
@@ -8,0 +8,0 @@ var CliUx = require('./CliUx'); |
@@ -128,5 +128,8 @@ | ||
else | ||
fn(err, stringifyOnce(clu, undefined, 0)); | ||
fn(err, clu); | ||
}); | ||
}, | ||
stopProcessName : function(opts, fn) { | ||
God.stopProcessName(opts.name, fn); | ||
}, | ||
stopAll : function(opts, fn) { | ||
@@ -133,0 +136,0 @@ God.stopAll(fn); |
{ | ||
"name": "pm2", | ||
"preferGlobal": "true", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"engines" : { | ||
@@ -51,3 +51,3 @@ "node" : ">=0.8" | ||
"cli-table" : "0.2.0", | ||
"multimeter" : "git://github.com/Unitech/node-multimeter.git", | ||
"pm2-multimeter" : "0.1.2", | ||
"usage" : "0.3.7", | ||
@@ -54,0 +54,0 @@ "axon-rpc" : "0.0.2", |
@@ -19,5 +19,28 @@ | ||
describe('Special functions for God', function() { | ||
it('should kill a process by name', function(done) { | ||
God.prepare({ | ||
pm_exec_path : path.resolve(process.cwd(), 'test/fixtures/echo.js'), | ||
pm_err_log_path : path.resolve(process.cwd(), 'test/errLog.log'), | ||
pm_out_log_path : path.resolve(process.cwd(), 'test/outLog.log'), | ||
pm_pid_path : path.resolve(process.cwd(), 'test/child'), | ||
instances : 2 | ||
}, function(err, procs) { | ||
God.getFormatedProcesses().length.should.equal(2); | ||
God.stopProcessName('echo.js', function() { | ||
God.getFormatedProcesses().length.should.equal(0); | ||
God.stopAll(done); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('One process', function() { | ||
var proc, pid; | ||
before(function(done) { | ||
God.stopAll(done); | ||
}); | ||
after(function(done) { | ||
@@ -108,2 +131,3 @@ God.stopAll(done); | ||
}); | ||
it('should cron restart', function(done) { | ||
@@ -120,3 +144,3 @@ God.prepare({ | ||
setTimeout(function() { | ||
God.getFormatedProcesses()[0].opts.restart_time.should.be.above(1); | ||
God.getFormatedProcesses()[0].opts.restart_time.should.be.above(0); | ||
God.stopAll(done); | ||
@@ -128,2 +152,3 @@ }, 2200); | ||
}); |
@@ -57,2 +57,3 @@ | ||
methods.should.have.property('stopAll'); | ||
methods.should.have.property('stopProcessName'); | ||
methods.should.have.property('killMe'); | ||
@@ -59,0 +60,0 @@ methods.should.have.property('daemonData'); |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
465774
1242
0
57
+ Addedpm2-multimeter@0.1.2
+ Addedcharm@0.1.2(transitive)
+ Addedpm2-multimeter@0.1.2(transitive)
- Removedmultimeter@git://github.com/Unitech/node-multimeter.git