forked from FreeCodeCampChina/freecodecamp.cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pm2Start.js
31 lines (27 loc) · 774 Bytes
/
pm2Start.js
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
28
29
30
31
require('dotenv').load();
var pm2 = require('pm2');
var nodemailer = require('nodemailer');
var moment = require('moment-timezone');
var _ = require('lodash');
var instances = process.env.INSTANCES || 1;
var serverName = process.env.SERVER_NAME || 'server';
var maxMemory = process.env.MAX_MEMORY || '390M';
var mailReceiver = process.env.MAIL_RECEIVER || false;
pm2.connect(function() {
pm2.start({
name: serverName,
script: 'server/production-start.js',
'exec_mode': 'cluster',
instances: instances,
'max_memory_restart': maxMemory,
'NODE_ENV': 'production'
}, function() {
console.log(
'pm2 started %s with %s instances at %s max memory',
serverName,
instances,
maxMemory
);
pm2.disconnect();
});
});