mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
Merge branch 'development' of github.com:Unitech/pm2 into development
This commit is contained in:
commit
1f2f9172de
@ -10,6 +10,7 @@
|
||||
- #2663 allow to directly output json when logging (via log_type for JSON and --log-type via CLI)
|
||||
- #2675 fix path when installing language module like typescript
|
||||
- #2674 increase restart timeout for systemd startup
|
||||
- #2564 allow to operate process (restart/reload/stop/delete) with regex
|
||||
|
||||
## 2.3.0
|
||||
|
||||
|
||||
24
lib/API.js
24
lib/API.js
@ -1309,6 +1309,30 @@ API.prototype._operate = function(action_name, process_name, envs, cb) {
|
||||
return processIds(ids, cb);
|
||||
});
|
||||
}
|
||||
// operate using regex
|
||||
else if (isNaN(process_name) && process_name[0] === '/' && process_name[process_name.length - 1] === '/') {
|
||||
var regex = new RegExp(process_name.replace(/\//g, ''));
|
||||
|
||||
that.Client.executeRemote('getMonitorData', {}, function(err, list) {
|
||||
if (err) {
|
||||
Common.printError('Error retrieving process list: ' + err);
|
||||
return cb(err);
|
||||
}
|
||||
var found_proc = [];
|
||||
list.forEach(function(proc) {
|
||||
if (regex.test(proc.pm2_env.name)) {
|
||||
found_proc.push(proc.pm_id);
|
||||
}
|
||||
});
|
||||
|
||||
if (found_proc.length === 0) {
|
||||
Common.printError(conf.PREFIX_MSG_WARNING + 'No process found');
|
||||
return cb ? cb(new Error('process name not found')) : that.exitCli(conf.ERROR_EXIT);
|
||||
}
|
||||
|
||||
return processIds(found_proc, cb);
|
||||
});
|
||||
}
|
||||
else if (isNaN(process_name)) {
|
||||
/**
|
||||
* We can not stop or delete a module but we can restart it
|
||||
|
||||
@ -180,8 +180,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^3",
|
||||
"should": "^11",
|
||||
"better-assert": "^1.0.0"
|
||||
"should": "^11"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"gkt": "https://tgz.pm2.io/gkt-1.0.0.tgz"
|
||||
|
||||
27
test/bash/operate-regex.sh
Normal file
27
test/bash/operate-regex.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SRC=$(cd $(dirname "$0"); pwd)
|
||||
source "${SRC}/include.sh"
|
||||
|
||||
cd $file_path
|
||||
|
||||
$pm2 start echo.js --name "echo-3"
|
||||
$pm2 start echo.js --name "echo-1"
|
||||
$pm2 start echo.js --name "echo-2"
|
||||
|
||||
sleep 0.5
|
||||
|
||||
should 'should have started 3 apps' 'online' 3
|
||||
|
||||
$pm2 stop /echo-[1,2]/
|
||||
|
||||
should 'should have stopped 2 apps' 'stopped' 2
|
||||
should 'only one app should still be online' 'online' 1
|
||||
|
||||
$pm2 stop /echo-3/
|
||||
should 'should have stopped 1 apps' 'online' 0
|
||||
|
||||
$pm2 restart /echo-[1,2]/
|
||||
|
||||
should 'should have restarted 2 apps' 'online' 2
|
||||
|
||||
@ -121,6 +121,8 @@ bash ./test/bash/log-null.sh
|
||||
spec "Logging path set to null"
|
||||
bash ./test/bash/log-json.sh
|
||||
spec "Logging directly to file in json"
|
||||
bash ./test/bash/operate-regex.sh
|
||||
spec "Operate process that match regex"
|
||||
|
||||
# Issues related
|
||||
bash ./test/bash/issues/2337.sh
|
||||
|
||||
@ -3,7 +3,6 @@ process.env.NODE_ENV = 'test';
|
||||
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
var Plan = require('../helpers/plan.js');
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
|
||||
// Change to current folder
|
||||
|
||||
@ -5,7 +5,6 @@ process.env.NODE_ENV = 'test';
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var fs = require('fs');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
|
||||
describe('Max memory restart programmatic', function() {
|
||||
|
||||
@ -4,7 +4,6 @@ process.env.PM2_WORKER_INTERVAL = 1000;
|
||||
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
|
||||
// Change to current folder
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
|
||||
describe('Misc commands', function() {
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
//process.env.NODE_ENV ='test';
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
|
||||
describe('PM2 programmatic calls', function() {
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
|
||||
describe('PM2 programmatic calls', function() {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
var PM2 = require('../..');
|
||||
var should = require('should');
|
||||
var assert = require('better-assert');
|
||||
var path = require('path');
|
||||
|
||||
describe('Signal kill (+delayed)', function() {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
var should = require('should')
|
||||
var assert = require('better-assert');
|
||||
var should = require('should');
|
||||
var p = require('path');
|
||||
var fs = require('fs')
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user