forked from Shyam-Chen/Express-Starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocesses.js
More file actions
27 lines (24 loc) · 833 Bytes
/
processes.js
File metadata and controls
27 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const pm2 = require('pm2');
pm2.connect(() => {
pm2.start(
{
name: 'Backend-Starter-Kit',
script: `${__dirname}/dist/api.js`,
max_memory_restart: `${process.env.WEB_MEMORY || 512}M`,
exec_mode: 'cluster',
instances: process.env.WEB_CONCURRENCY || -1,
},
(err) => {
if (err) {
console.error(`Error while launching applications ${err.stack || err}.`);
return;
}
console.log('PM2 and application has been succesfully started.');
pm2.launchBus((errLb, bus) => {
console.log('PM2: Log streaming started.');
bus.on('log:out', packet => console.log(`App (out): ${packet.process.name} - ${packet.data}`));
bus.on('log:err', packet => console.error(`App (err): ${packet.process.name} - ${packet.data}`));
});
},
);
});