Skip to content

Commit dcd190b

Browse files
committed
Update README.md and fully restructure tests
1 parent a467a3f commit dcd190b

File tree

152 files changed

+370
-502
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+370
-502
lines changed

README.md

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
<br/>
2828
</div>
2929

30-
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.
30+
PM2 is a Production Runtime and 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 facilitate common Devops tasks.
3131

3232
Starting an application in production mode is as easy as:
3333

3434
```bash
3535
$ pm2 start app.js
3636
```
3737

38-
PM2 is constantly assailed by [more than 1400 tests](https://travis-ci.org/Unitech/pm2).
38+
PM2 is constantly assailed by [more than 1800 tests](https://travis-ci.org/Unitech/pm2).
3939

4040
Official website: [http://pm2.keymetrics.io/](http://pm2.keymetrics.io/)
4141

@@ -64,9 +64,10 @@ Your app is now daemonized, monitored and kept alive forever.
6464

6565
## Container Support
6666

67-
Using Containers? We got your back with pm2-runtime, a dedicated command for running Node.js in containers and our [officialy suported Docker image](https://hub.docker.com/r/keymetrics/pm2/).
67+
Using Containers? With the dropin replacement command for `node`, called `pm2-runtime`, run your Node.js application in the best production environment.
68+
We also offer an [officialy suported Docker image](https://hub.docker.com/r/keymetrics/pm2/).
6869

69-
Using it:
70+
Using it is seamless:
7071

7172
```
7273
FROM keymetrics/pm2:latest-alpine
@@ -76,9 +77,10 @@ CMD [ "pm2-runtime", "ecosystem.config.js" ]
7677

7778
[Read More about the dedicated integration](http://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/)
7879

79-
## Monitor PM2 and Applications
80+
## Monitor PM2 and Applications with our SaaS
8081

81-
To monitor your applications just type:
82+
Once you deploy your application in production, monitor, debug and profile it externally with our [SaaS Monitoring](https://keymetrics.io):
83+
To start monitoring applications from the terminal:
8284

8385
```bash
8486
$ pm2 register
@@ -162,6 +164,8 @@ $ pm2 uninstall pm2-logrotate # Uninstall module
162164
$ pm2 publish # Increment version, git push and npm publish
163165
```
164166

167+
Also check out the [example folder](https://github.com/Unitech/pm2/tree/master/examples) to discover all features.
168+
165169
### Process management
166170

167171
Once applications are started you can list and manage them easily:
@@ -174,17 +178,13 @@ Listing all running processes:
174178
$ pm2 list
175179
```
176180

177-
Managing your processes is straightforward:
181+
Managing processes is straightforward:
178182

179183
```bash
180184
$ pm2 stop <app_name|id|'all'|json_conf>
181185
$ pm2 restart <app_name|id|'all'|json_conf>
182186
$ pm2 delete <app_name|id|'all'|json_conf>
183187
```
184-
To make sure it re-evaluates enviroment variables declared in your `json_conf` pass it as argument, and optionally your custom `env` name from your `json_conf` if any:
185-
```bash
186-
$ pm2 restart <json_conf> [--env <env_name>]
187-
```
188188

189189
To have more details on a specific process:
190190

@@ -196,9 +196,9 @@ $ pm2 describe <id|app_name>
196196

197197
### Load Balancing & Zero second Downtime Reload
198198

199-
When an application is started with the -i <instance_number> option, the **Cluster Mode** is enabled.
199+
When an application is started with the -i <instance_number> parameter, the **Cluster Mode** is activated.
200200

201-
The Cluster Mode starts <instance_number> instances of your app and automatically load balance HTTP/TCP/UDP between each instance. This allows to increase overall performance depending on the number of CPUs available.
201+
The Cluster Mode starts <instance_number> instances of your app and automatically load balance HTTP/TCP/UDP between each instances. This allows to increase overall performance and reliability depending on the number of CPUs available.
202202

203203
Seamlessly supported by all major Node.js frameworks and any Node.js applications without any code change:
204204

@@ -207,16 +207,19 @@ Seamlessly supported by all major Node.js frameworks and any Node.js application
207207
Main commands:
208208

209209
```bash
210-
$ pm2 start app.js -i max # Enable load-balancer and start 'max' instances (cpu nb)
210+
# Enable load-balancer and start 'max' instances (Depending on CPU number)
211+
$ pm2 start app.js -i max
211212

212-
$ pm2 reload all # Zero second dowtime reload
213+
# Update your application with Zero Downtime Reload (requests are not lost)
214+
$ pm2 reload all
213215

214-
$ pm2 scale <app_name> <instance_number> # Increase / Decrease process number
216+
# Increase / Decrease process number
217+
$ pm2 scale <app_name> <instance_number>
215218
```
216219

217220
[More informations about how PM2 make clustering easy](https://keymetrics.io/2015/03/26/pm2-clustering-made-easy/)
218221

219-
### CPU / Memory Monitoring
222+
### Terminal Based Monitoring
220223

221224
![Monit](https://github.com/Unitech/pm2/raw/master/pres/pm2-monit.png)
222225

@@ -226,16 +229,49 @@ Monitoring all processes launched:
226229
$ pm2 monit
227230
```
228231

232+
### Expose Custom Metrics
233+
234+
To get more insights on how your application behave, plug custom metrics inside your code and monitor them with the `pm2 monit` command:
235+
236+
In your project install [pmx](https://github.com/keymetrics/pmx):
237+
238+
```bash
239+
$ npm install pmx --save
240+
```
241+
242+
Then plug a custom metric:
243+
244+
```javascript
245+
var Probe = require('pmx').probe();
246+
247+
var counter = 1;
248+
249+
var metric = Probe.metric({
250+
name : 'Counter',
251+
value : function() {
252+
return counter;
253+
}
254+
});
255+
256+
setInterval(function() {
257+
counter++;
258+
}, 1000);
259+
```
260+
261+
Metric, Counter, Histogram and Meters are available *[documentation](http://pm2.keymetrics.io/docs/usage/process-metrics/)*
262+
229263
### Log facilities
230264

231265
![Monit](https://github.com/unitech/pm2/raw/master/pres/pm2-logs.png)
232266

233-
Displaying logs of a specified process or all processes, in real time. Standard, Raw, JSON and formated output are available.
267+
Displaying logs of a specified process or all processes, in real time is easy:
234268

235269
```bash
236270
$ pm2 logs ['all'|app_name|app_id] [--json] [--format] [--raw]
237271
```
238272

273+
Standard, Raw, JSON and formated output are available.
274+
239275
Examples:
240276

241277
```bash
@@ -251,7 +287,7 @@ $ pm2 reloadLogs # Reload all logs
251287

252288
### Startup script generation
253289

254-
PM2 can generate and configure a startup script to keep PM2 and your processes alive at every server restart.
290+
PM2 can generates and configure a startup script to keep PM2 and your processes alive at every server restart.
255291

256292
Supports init systems like: **systemd** (Ubuntu 16, CentOS, Arch), **upstart** (Ubuntu 14/12), **launchd** (MacOSx, Darwin), **rc.d** (FreeBSD).
257293

examples/binary/ecosystem.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

examples/binary/ls.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/cluster-http/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
To start http application in cluster mode:
3+
4+
```bash
5+
$ pm2 start ecosystem.config.js
6+
# OR
7+
$ pm2 start http.js -i max
8+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
apps : [{
3+
name : 'clustered_http',
4+
script : './http.js',
5+
instances : 'max',
6+
exec_mode : 'cluster',
7+
env : {
8+
PORT : 8002
9+
}
10+
}, {
11+
name : 'forked_app',
12+
script : './http.js',
13+
env : {
14+
PORT : 8001
15+
}
16+
}]
17+
}

examples/cluster-tcp/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
To start tcp application in cluster mode:
3+
4+
```bash
5+
$ pm2 start ecosystem.config.js
6+
# OR
7+
$ pm2 start tcp.js -i max
8+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ var server = http.createServer(function(req, res) {
55
res.writeHead(200);
66
res.end('hey');
77
}).listen(process.env.PORT || 8000, function() {
8-
console.log('App listening on port %d in env %s', process.env.PORT || 8000, process.env.NODE_ENV);
8+
console.log('App listening on port %d', server.address().port);
99
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
apps : [{
3+
name : 'clustered_tcp',
4+
script : './tcp.js',
5+
instances : 'max',
6+
exec_mode : 'cluster',
7+
env : {
8+
PORT : 8002
9+
}
10+
}, {
11+
name : 'forked_tcp',
12+
script : './tcp.js',
13+
env : {
14+
PORT : 8001
15+
}
16+
}]
17+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ var net = require('net');
22

33
var server = net.createServer(function (socket) {
44
socket.write('Welcome to the Telnet server of the process' + (process.env.NODE_APP_INSTANCE || 'must be run on pm2'));
5-
}).listen(8888, function() {
6-
console.log('Listening on port %s', 8888);
5+
}).listen(process.env.PORT || 8888, function() {
6+
console.log('Listening on port %s', server.address().port);
77
});

0 commit comments

Comments
 (0)