Skip to content

Commit dfd33cb

Browse files
committed
Merge pull request #1347 from Unitech/development
Release v0.14.0 Hellfire
2 parents cd6f664 + c355a15 commit dfd33cb

38 files changed

+851
-534
lines changed

ADVANCED_README.md

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Quick start
66

77
- [Installation](#a1)
8+
- [Folder structure](#pm2-folder-structure)
89
- [Usage](#a2)
910
- [Examples](#a3)
1011
- [Different ways to launch a process](#raw-examples)
@@ -21,6 +22,7 @@
2122
- [Monitoring CPU/Memory usage](#a7)
2223
- [Logs management](#a9)
2324
- [Clustering](#a5)
25+
- [Multiple PM2 on the same server](#multiple-pm2)
2426
- [Watch & Restart](#watch--restart)
2527
- [Reloading without downtime](#hot-reload--0s-reload)
2628
- [Make PM2 restart on server reboot](#a8)
@@ -87,6 +89,19 @@ If the above fails use:
8789
$ npm install git://github.com/Unitech/pm2#master -g
8890
```
8991

92+
<a name="pm2-folder-structure"/>
93+
## PM2 configuration folder structure
94+
95+
Once PM2 is started, it automatically create these folders:
96+
- `$HOME/.pm2` will contain all PM2 related files
97+
- `$HOME/.pm2/logs` will contain all applications logs
98+
- `$HOME/.pm2/pids` will contain all applications pids
99+
- `$HOME/.pm2/pm2.log` PM2 logs
100+
- `$HOME/.pm2/pm2.pid` PM2 pid
101+
- `$HOME/.pm2/rpc.sock` Socket file for remote commands
102+
- `$HOME/.pm2/pub.sock` Socket file for publishable events
103+
- `$HOME/.pm2/conf.js` PM2 Configuration
104+
90105
<a name="a2"/>
91106
## Usage
92107

@@ -516,7 +531,7 @@ $ pm2 start big-array.js --max-memory-restart 20M
516531
### Programmatic
517532

518533
```
519-
pm2.start({{
534+
pm2.start({
520535
name : "max_mem",
521536
script : "big-array.js",
522537
max_memory_restart : "20M"
@@ -583,17 +598,39 @@ Just use the `-u <username>` option !
583598
$ pm2 startup ubuntu -u www
584599
```
585600

601+
<a name="multiple-pm2"/>
586602
### Related commands
587603

588604
Dump all processes status and environment managed by PM2:
605+
589606
```bash
590-
$ pm2 dump
607+
$ pm2 [dump|save]
591608
```
609+
592610
It populates the file `~/.pm2/dump.pm2` by default.
593611

594612
To bring back the latest dump:
613+
614+
```bash
615+
$ pm2 resurrect
616+
```
617+
618+
## Multiple PM2 on the same server
619+
620+
The client and daemon communicates via socket files available in $HOME/.pm2/[pub.sock|rpc.sock]
621+
622+
You can start multiple PM2 instances by changing the `PM2_HOME` environmnent variable.
623+
595624
```bash
596-
$ pm2 [resurrect|save]
625+
$ PM2_HOME='.pm2' pm2 start echo.js --name="echo-node-1"
626+
$ PM2_HOME='.pm3' pm2 start echo.js --name="echo-node-2"
627+
```
628+
629+
This will start two different PM2 instances. To list processes managed by each different instances do:
630+
631+
```bash
632+
$ PM2_HOME='.pm2' pm2 list
633+
$ PM2_HOME='.pm3' pm2 list
597634
```
598635

599636
## Watch & Restart
@@ -638,8 +675,7 @@ var watch_options = {
638675

639676
## JSON app declaration
640677

641-
642-
PM2 empowers your process management workflow, by allowing you to fine-tune the behavior, options, environment variables, logs files... of each process you need to manage via JSON configuration.
678+
PM2 empowers your process management workflow, by allowing you to fine-tune the behavior, options, environment variables, logs files... of each process you need to manage via JSON/JSON5/JS configuration.
643679

644680
It's particularly usefull for micro service based applications.
645681

@@ -680,11 +716,19 @@ $ pm2 start processes.json
680716
# Stop
681717
$ pm2 stop processes.json
682718

719+
# Restart
720+
$ pm2 start processes.json
721+
## Or
722+
$ pm2 restart processes.json
723+
724+
# Reload
725+
$ pm2 reload processes.json
726+
727+
# Graceful Reload
728+
$ pm2 gracefulReload processes.json
729+
683730
# Delete from PM2
684731
$ pm2 delete processes.json
685-
686-
# Restart all
687-
$ pm2 restart processes.json
688732
```
689733

690734
### Options

CHANGELOG.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@
55
- YAML support for apps declarations
66
- Improve app declaration file parsing (log_file, out_file, error_file)
77

8+
# 0.14.0 - CrystalClear (pre 1.0)
9+
10+
- Removed: pm2.startJSON() method, now call pm2.start()
11+
- API Change: pm2 start <app_name|app_id> restart an application already launched
12+
- API Change: pm2 start <json> restart all json apps if already launched
13+
- pm2 start all - restart all applications
14+
- pm2 reload <json_file> possible
15+
- pm2 gracefulReload <json_file> possible
16+
- Smart start (pm2 start app.js ; pm2 stop app ; pm2 start app)
17+
- Reduced memory footprint
18+
- Reduced pipelined data
19+
- Reduced CPU usage
20+
- Faster command processing
21+
- Upgrade shelljs, semver, colors, chalk, coffee-script, async, json-stringify-safe, cron, debug, commander
22+
- Fix: launchBus() only connects and disconnects once
23+
24+
- Refactored `pm2 logs` :
25+
- Now you don't need to install tail on Windows
26+
- You don't need to Ctrl^C and `pm2 logs` again when a new app is launched (this one will be detected and added to the real-time logs output)
27+
- Logs are shown in chronological order at a file level (modified date)
28+
- More verbosity : tailed logs are explicitely separated from the real-time logs
29+
- Real-time logs now use the `bus` event emitter
30+
- PM2 logs added to the `bus`
31+
- `--lines <n>` and `--raw` flags available for `pm2 logs` command
32+
- New flag : '--timestamp [format]' // default format is 'YYYY-MM-DD-HH:mm:ss'
33+
- Now you can exclusively show PM2 logs by doing `pm2 logs PM2`
34+
835
# 0.12.16 (Current stable)
936

1037
- Feature : File transmission added in Agent
@@ -364,7 +391,7 @@ Big thanks to @Tjatse !
364391

365392
- Adds option to switch to a different user/group before starting a managed process #329
366393
- watch doesnt watch node_module folder
367-
- default log files and pid files location can be overidded by PM2_LOG_DIR / PM2_PID_DIR
394+
- default log files and pid files location can be overrided by PM2_LOG_DIR / PM2_PID_DIR
368395

369396

370397
# 0.8.1

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ Compatible with [io.js](https://github.com/iojs/io.js) and [Node.js](https://git
1616
Compatible with CoffeeScript.
1717
Works on Linux (stable) & MacOSx (stable) & Windows (stable).
1818

19-
[![NPM version](https://badge.fury.io/js/pm2.svg)](http://badge.fury.io/js/pm2) [![Gitter](https://badges.gitter.im/Unitech/PM2.svg)](https://gitter.im/Unitech/PM2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://api.travis-ci.org/Unitech/PM2.svg?branch=master)](https://travis-ci.org/Unitech/PM2) [![Inline docs](http://inch-ci.org/github/unitech/pm2.svg?branch=master)](http://inch-ci.org/github/unitech/pm2)
20-
19+
[![Version npm](https://img.shields.io/npm/v/pm2.svg?style=flat-square)](https://www.npmjs.com/package/pm2)[![NPM Downloads](https://img.shields.io/npm/dm/pm2.svg?style=flat-square)](https://www.npmjs.com/package/pm2)[![Build Status](https://img.shields.io/travis/Unitech/PM2.svg?style=flat-square)](https://travis-ci.org/Unitech/PM2)[![Dependencies](https://img.shields.io/david/Unitech/pm2.svg?style=flat-square)](https://david-dm.org/Unitech/pm2)
2120

2221
[![NPM](https://nodei.co/npm/pm2.png?downloads=true&downloadRank=true)](https://nodei.co/npm/pm2/)
2322

@@ -71,15 +70,15 @@ $ pm2 list
7170
Managing your processes is straightforward:
7271

7372
```bash
74-
$ pm2 stop <app_name|id|all>
75-
$ pm2 restart <app_name|id|all>
76-
$ pm2 delete <app_name|id|all>
73+
$ pm2 stop <app_name|id|'all'|json_conf>
74+
$ pm2 restart <app_name|id|'all'|json_conf>
75+
$ pm2 delete <app_name|id|'all'|json_conf>
7776
```
7877

7978
To have more details on a specific process:
8079

8180
```bash
82-
$ pm2 describe 0
81+
$ pm2 describe <id|app_name>
8382
```
8483

8584
### CPU / Memory Monitoring
@@ -100,11 +99,11 @@ Displaying logs of a specified process or all processes, in real time:
10099

101100
```bash
102101
$ pm2 logs
103-
$ pm2 logs big-api
102+
$ pm2 logs <app_name>
104103
$ pm2 logs --raw
105104
$ pm2 logs --lines 5
106105
$ pm2 logs --timestamp "HH:mm:ss"
107-
$ pm2 logs <app_name>
106+
$ pm2 logs WEB-API --lines 0 --timestamp "HH:mm"
108107

109108
$ pm2 flush # Clear all the logs
110109
```

bin/pm2

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ commander.on('--help', function() {
7272
console.log(' $ pm2 kill');
7373
console.log('');
7474
console.log(' Update pm2 :');
75-
console.log(' $ npm install pm2@latest -g ; pm2 updatePM2');
75+
console.log(' $ npm install pm2@latest -g ; pm2 update');
7676
console.log('');
7777
console.log(' More examples in https://github.com/Unitech/pm2#usagefeatures');
7878
console.log('');
@@ -110,8 +110,8 @@ function beginCommandProcessing() {
110110
console.log('Local PM2 version:', chalk.blue.bold(pkg.version));
111111
console.log('');
112112
}
113-
commander.parse(process.argv);
114113
});
114+
commander.parse(process.argv);
115115
}
116116

117117
if (process.argv.indexOf('--no-daemon') > -1) {
@@ -154,7 +154,7 @@ function failOnUnknown(fn) {
154154
//
155155
// Start command
156156
//
157-
commander.command('start <file|json|stdin>')
157+
commander.command('start <file|json|stdin|app_name|pm_id>')
158158
.option('--watch', 'Watch folder for changes')
159159
.description('start and daemonize an app')
160160
.action(function(cmd) {
@@ -568,17 +568,24 @@ commander.command('reloadLogs')
568568
//
569569
commander.command('logs [id|name]')
570570
.option('--raw', 'logs without timestamps and other PM2 indicators')
571-
.option('--lines <N>', 'output the last N lines, instead of the last 20')
571+
.option('--lines <n>', 'output the last N lines, instead of the last 20 by default')
572+
.option('--timestamp [format]', 'add timestamps (default format YYYY-MM-DD-HH:mm:ss)')
572573
.description('stream logs file. Default stream all logs')
573574
.action(function(id, cmd) {
574575
var line = 20;
575576
var raw = false;
577+
var timestamp = false;
578+
576579
if(!isNaN(cmd.lines)){
577580
line = parseInt(cmd.lines);
578581
}
582+
579583
if (cmd.parent.rawArgs.indexOf('--raw') !== -1)
580584
raw = true;
581-
CLI.streamLogs(id, line, raw);
585+
586+
if (cmd.timestamp)
587+
timestamp = typeof cmd.timestamp === 'string' ? cmd.timestamp : 'YYYY-MM-DD-HH:mm:ss';
588+
CLI.streamLogs(id, line, raw, timestamp);
582589
});
583590

584591

constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var csts = {
5959
CLUSTER_MODE_ID : 'cluster_mode',
6060
FORK_MODE_ID : 'fork_mode',
6161

62-
KEYMETRICS_ROOT_URL : 'root.keymetrics.io',
62+
KEYMETRICS_ROOT_URL : process.env.KEYMETRICS_NODE || 'root.keymetrics.io',
6363

6464
DEFAULT_MODULE_JSON : 'package.json',
6565

doc/MODULE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A PM2 module is basically a NPM module. But this time it's not a library, but a
55

66
Internally it embeds the NPM install procedure. So a PM2 module will be published to NPM and installed from NPM.
77

8-
![Process listing](https://github.com/unitech/pm2/raw/poc-plugin/pres/pm2-module.png)
8+
![Process listing](https://github.com/unitech/pm2/raw/master/pres/pm2-module.png)
99

1010
## Basics
1111

@@ -98,7 +98,7 @@ An object can be passed to initModule:
9898
latency : false,
9999
versioning : false,
100100
show_module_meta : false
101-
pid : pid_number (overidde pid to monitor // use pmx.getPID(FILE)),
101+
pid : pid_number (override pid to monitor // use pmx.getPID(FILE)),
102102
comment : string (comment to be displayed in dashboard)
103103
}
104104
```

0 commit comments

Comments
 (0)