This commit is contained in:
Unitech 2015-12-08 23:05:21 +01:00
parent 62388fc27a
commit 02fbe7b24d
4 changed files with 67 additions and 8 deletions

View File

@ -8,6 +8,7 @@
### 0.15.11
- [#1825] Process management commands (start/restart/stop/delete) can take multiple arguments
- [#1822] Add new method pm2.sendDataToProcessId(type|data|id) to send data to processes
- [#1819] Send SIGINT signal to process instead of SIGTERM
- [#1819][#1794][#1765] Avoid writing on std err/out when process is disconnected

42
bin/pm2
View File

@ -9,6 +9,7 @@ var p = path;
var util = require('util');
var cronJob = require('cron').CronJob;
var chalk = require('chalk');
var async = require('async');
var debug = require('debug')('pm2:cli');
var Satan = require('../lib/Satan');
@ -191,7 +192,7 @@ function failOnUnknown(fn) {
//
// Start command
//
commander.command('start <file|json|stdin|app_name|pm_id>')
commander.command('start <file|json|stdin|app_name|pm_id...>')
.option('--watch', 'Watch folder for changes')
.description('start and daemonize an app')
.action(function(cmd) {
@ -204,7 +205,13 @@ commander.command('start <file|json|stdin|app_name|pm_id>')
});
}
else {
CLI.start(cmd, commander);
async.forEachLimit(cmd, 1, function(script, next) {
CLI.start(script, commander, function() {
next();
});
}, function(err) {
CLI.list();
});
}
});
@ -235,21 +242,34 @@ commander.command('startOrGracefulReload <json>')
//
// Stop specific id
//
commander.command('stop <id|name|all|json|stdin>')
commander.command('stop <id|name|all|json|stdin...>')
.option('--watch', 'Stop watching folder for changes')
.description('stop a process (to start it again, do pm2 restart <app>)')
.action(function(param) {
CLI.stop(param);
async.forEachLimit(param, 1, function(script, next) {
CLI.stop(script, function() {
next();
});
}, function(err) {
CLI.list();
});
});
//
// Stop All processes
//
commander.command('restart <id|name|all|json|stdin>')
commander.command('restart <id|name|all|json|stdin...>')
.option('--watch', 'Toggle watching folder for changes')
.description('restart a process')
.action(function(param) {
CLI.restart(param);
async.forEachLimit(param, 1, function(script, next) {
CLI.restart(script, function() {
next();
});
}, function(err) {
CLI.list();
});
});
//
@ -288,7 +308,7 @@ commander.command('gracefulReload <name|all>')
//
// Stop and delete a process by name from database
//
commander.command('delete <name|id|script|all|json|stdin>')
commander.command('delete <name|id|script|all|json|stdin...>')
.description('stop and delete a process from pm2 process list')
.action(function(name) {
if (name == "-") {
@ -299,7 +319,13 @@ commander.command('delete <name|id|script|all|json|stdin>')
CLI.delete(param, 'pipe');
});
} else
CLI.delete(name,'');
async.forEachLimit(name, 1, function(script, next) {
CLI.delete(script,'', function(err) {
next();
});
}, function(err) {
CLI.list();
});
});
//

30
test/bash/multiparam.sh Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
SRC=$(cd $(dirname "$0"); pwd)
source "${SRC}/include.sh"
cd $file_path
############# TEST
echo -e "\033[1mRunning tests:\033[0m"
$pm2 kill
spec "kill daemon"
## Start
$pm2 start child.js echo.js server.js
should 'should app be online' 'online' 3
## Restart
$pm2 restart child echo server
should 'should app be online' 'online' 3
should 'should all script been restarted one time' 'restart_time: 1' 3
## Stop
$pm2 stop child echo server
should 'should app be stopped' 'stopped' 3
## Delete
$pm2 delete child echo server
shouldnot 'should app be deleted' 'stopped' 3

View File

@ -30,6 +30,8 @@ bash ./test/bash/smart-start.sh
spec "smart start test"
bash ./test/bash/cli.sh
spec "CLI basic test"
bash ./test/bash/multiparam.sh
spec "Multiparam process management"
bash ./test/bash/json_file.sh
spec "JSON file test"
bash ./test/bash/json-reload.sh