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
2d7042032e
@ -118,7 +118,6 @@ $ pm2 monit # Monitor all processes
|
||||
# Logs
|
||||
|
||||
$ pm2 logs [--raw] # Display all processes logs in streaming
|
||||
$ pm2 ilogs # Advanced termcaps interface to display logs
|
||||
$ pm2 flush # Empty all log file
|
||||
$ pm2 reloadLogs # Reload all logs
|
||||
|
||||
|
||||
16
CHANGELOG.md
16
CHANGELOG.md
@ -5,12 +5,20 @@
|
||||
- YAML support for apps declarations
|
||||
- Improve app declaration file parsing (log_file, out_file, error_file)
|
||||
|
||||
# 0.12.13 (In progress)
|
||||
# 0.12.14 (Next release)
|
||||
|
||||
- Enhanced: Call reload instead of restart when max-memory-limit reached
|
||||
- Enhanced: Modules are compatible ES6 by default by adding --harmony flag
|
||||
- `ilogs` is no longer part of PM2
|
||||
|
||||
# 0.12.12 (Current stable)
|
||||
# 0.12.13 (Current Stable)
|
||||
|
||||
- Enhanced : PM2 doesn't leave processes behind when it crashes
|
||||
- Enhanced : Call reload instead of restart when max-memory-limit reached
|
||||
- Enhanced : Modules are compatible ES6 by default by adding --harmony flag
|
||||
- Enhanced : Dump feature is now smarter
|
||||
- Fix #1206 : fix `pm2 logs` bug when merged_logs
|
||||
- Fix : pm2 scale doesn't try to scale a fork_mode process
|
||||
|
||||
# 0.12.12
|
||||
|
||||
- `pm2 logs --raw` flag : show logs in raw format
|
||||
- New command: pm2 scale <app_name> <number> - scale up/down an application
|
||||
|
||||
14
README.md
14
README.md
@ -1,6 +1,8 @@
|
||||

|
||||
|
||||
PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
|
||||
**P**(rocess) **M**(anager) **2**
|
||||
|
||||
PM2 is a production process manager for Node.js / io.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
|
||||
|
||||
Starting an application in production mode is as easy as:
|
||||
|
||||
@ -42,10 +44,10 @@ var pm2 = require('pm2');
|
||||
|
||||
pm2.connect(function() {
|
||||
pm2.start({
|
||||
script : 'app.js',
|
||||
exec_mode : 'cluster',
|
||||
instances : 4,
|
||||
max_memory_restart : '100M'
|
||||
script : 'app.js', // Script to be run
|
||||
exec_mode : 'cluster', // Allow your app to be clustered
|
||||
instances : 4, // Optional: Scale your app by 4
|
||||
max_memory_restart : '100M' // Optional: Restart your app if it reaches 100Mo
|
||||
}, function(err, apps) {
|
||||
pm2.disconnect();
|
||||
});
|
||||
@ -156,7 +158,7 @@ Thanks in advance and we hope that you like PM2!
|
||||
- [Using PM2 in your code](https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#programmatic-example)
|
||||
- [Deployment workflow](https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#deployment)
|
||||
- [Startup script generation (SystemV/Ubuntu/Gentoo/AWS)](https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#startup-script)
|
||||
- [Advanced log management (flush, reload, ilogs)](https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#a9)
|
||||
- [Advanced log management (flush, reload, logs)](https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#a9)
|
||||
- [GracefullReload](https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#a690)
|
||||
|
||||
## PM2 Full documentation
|
||||
|
||||
8
bin/pm2
8
bin/pm2
@ -217,7 +217,7 @@ commander.command('restart <id|name|all|json|stdin>')
|
||||
//
|
||||
// Scale up/down a process in cluster mode
|
||||
//
|
||||
commander.command('scale <app_name> <total_number>')
|
||||
commander.command('scale <app_name> <number>')
|
||||
.description('scale up/down a process in cluster mode depending on total_number param')
|
||||
.action(function(app_name, number) {
|
||||
CLI.scale(app_name, number);
|
||||
@ -580,12 +580,6 @@ commander.command('logs [id|name]')
|
||||
CLI.streamLogs(id, line, raw);
|
||||
});
|
||||
|
||||
commander.command('ilogs')
|
||||
.description('advanced interface to display logs')
|
||||
.action(function(id) {
|
||||
CLI.ilogs(id);
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
// Kill
|
||||
|
||||
16
lib/CLI.js
16
lib/CLI.js
@ -1243,6 +1243,11 @@ CLI.scale = function(app_name, number, cb) {
|
||||
return cb ? cb({msg: 'App not found'}) : exitCli(cst.ERROR_EXIT);
|
||||
}
|
||||
|
||||
if (procs[0].pm2_env.exec_mode !== 'cluster_mode') {
|
||||
printError(cst.PREFIX_MSG_ERR + 'Application %s is not in cluster mode', app_name);
|
||||
return cb ? cb({msg: 'App not in cluster mode'}) : exitCli(cst.ERROR_EXIT);
|
||||
}
|
||||
|
||||
var proc_number = procs.length;
|
||||
|
||||
if (typeof(number) === 'string' && number.indexOf('+') >= 0) {
|
||||
@ -1502,17 +1507,6 @@ function printLogs(id, lines, proc, raw) {
|
||||
}
|
||||
}
|
||||
|
||||
CLI.ilogs = function() {
|
||||
try {
|
||||
var logs = require('pm2-logs').init({
|
||||
format: 'MMMM Do YYYY, h:mm:ss a'
|
||||
});
|
||||
} catch(e) {
|
||||
printOut('pm2-logs module is not installed');
|
||||
CLI.streamLogs();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @method killDaemon
|
||||
|
||||
@ -123,6 +123,15 @@ module.exports = function(God) {
|
||||
var process_list = [];
|
||||
var apps = God.getFormatedProcesses();
|
||||
|
||||
// Don't override the actual dump file if process list is empty
|
||||
// unless user explicitely did `pm2 dump`.
|
||||
// This often happens when PM2 crashed, we don't want to override
|
||||
// the dump file with an empty list of process.
|
||||
if (!apps[0]) {
|
||||
debug('[PM2] Did not override dump file because list of processes is empty');
|
||||
return cb(null, {success:true, process_list: process_list});
|
||||
}
|
||||
|
||||
function fin(err) {
|
||||
try {
|
||||
fs.writeFileSync(cst.DUMP_FILE_PATH, JSON.stringify(process_list));
|
||||
@ -238,6 +247,7 @@ module.exports = function(God) {
|
||||
|
||||
console.log('Stopping app:%s id:%s', proc.pm2_env.name, proc.pm2_env.pm_id);
|
||||
proc.pm2_env.status = cst.STOPPING_STATUS;
|
||||
proc.pm2_env.vizion_running = false;
|
||||
|
||||
if (!proc.process.pid) {
|
||||
proc.pm2_env.status = cst.STOPPED_STATUS;
|
||||
|
||||
13
lib/Satan.js
13
lib/Satan.js
@ -632,7 +632,7 @@ Satan.unlock = function(opts, cb) {
|
||||
if (require.main === module) {
|
||||
|
||||
var pkg = require('../package.json');
|
||||
var God = require('./God.js');;
|
||||
var God = require('./God.js');
|
||||
|
||||
process.title = 'PM2 v' + pkg.version + ': God Daemon';
|
||||
|
||||
@ -642,11 +642,16 @@ if (require.main === module) {
|
||||
else {
|
||||
var d = domain.create();
|
||||
|
||||
d.on('error', function(err) {
|
||||
console.error('ERROR CAUGHT BY DOMAIN:\n' + (err.stack || err));
|
||||
d.once('error', function(err) {
|
||||
console.error('[PM2] Error caught by domain:\n' + (err.stack || err));
|
||||
|
||||
process.once('uncaughtException', function() {
|
||||
console.error('[PM2] Automatic `pm2 update` failed. Killing PM2 daemon and its processes...');
|
||||
process.emit('SIGTERM');
|
||||
});
|
||||
|
||||
God.dumpProcessList(function() {
|
||||
require('child_process').spawn('pm2', ['update'], {
|
||||
require('child_process').spawn('node', [process.env['_'], 'update'], {
|
||||
detached: true,
|
||||
stdio: [0,1,2]
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "pm2",
|
||||
"preferGlobal": "true",
|
||||
"version": "0.12.12",
|
||||
"version": "0.12.13",
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user