1# Start a cluster with forked process on all CPU Cores
2pm2 start server.js -i 0 --name 'test'
3pm2 show test
4pm2 log test
5
6# Zero downtime restart (round robbin restart through clusters)
7pm2 reload all
8
9# Display Logs
10pm2 logs accounting [--lines 1000]
11
12# CPU and memory usage
13pm2 monit
14
15# Delete App
16pm2 delete accounting
17
18# PM2 Ecosystem JSON (pm2.json)
19# "startpm2": "pm2 start pm2.json && pm2 log accounting"
20{
21 "apps" : [{
22 "name" : "accounting",
23 "script" : "bin/www",
24 "args" : ["-i", "0"],
25 "watch" : true,
26 "merge_logs" : true,
27 "env": {
28 "NODE_ENV": "production"
29 },
30 "env_production" : {
31 "NODE_ENV": "production"
32 },
33 "env_staging" : {
34 "NODE_ENV" : "staging",
35 "TEST" : true
36 }
37 }]
38 }
39
40# AIO
41
42## Dockerfile
43CMD [ "pm2-runtime", "pm2.json" ]
44## pm2.json
45{
46 "apps": [
47 {
48 "name": "nexus-api",
49 "script": "dist/app.js",
50 "kill_timeout" : 30000,
51 "instances": "0",
52 "exec_mode": "cluster",
53 "out_file": "/dev/null",
54 "error_file": "/dev/null",
55 "max_restarts": 1
56 }
57 ]
58}Created on 8/2/2017