May 2018
Intermediate to advanced
492 pages
12h 3m
English
There are many ways to manage server processes, to ensure restarts if the process crashes, and so on. We'll use PM2 (http://pm2.keymetrics.io/) because it's optimized for Node.js processes. It bundles process management and monitoring into one application.
Let's create a directory, init, in which to use PM2. The PM2 website suggests you install the tool globally but, as students of the Twelve Factor Application model, we recognize it's best to use explicitly declared dependencies and avoid global unmanaged dependencies.
Create a package.json file containing:
{ "name": "pm2deploy", "version": "1.0.0", "scripts": { "start": "pm2 start ecosystem.json", "stop": "pm2 stop ecosystem.json", "restart": "pm2 ...Read now
Unlock full access