add environmental vars to pm2start instead of hardcoding

This commit is contained in:
Berkeley Martinez
2015-08-13 15:40:54 -07:00
parent 146f42ef41
commit 8cfdd4c742

View File

@ -1,11 +1,13 @@
var pm2 = require('pm2'); var pm2 = require('pm2');
pm2.connect(function() { pm2.connect(function() {
pm2.start({ pm2.start({
name: 'server', name: process.env.SERVER_NAME || 'server',
script: 'server/production-start.js', script: 'server/production-start.js',
'exec_mode': 'cluster', 'exec_mode': 'cluster',
instances: '2', instances: process.env.INSTANCES || 1,
'max_memory_restart': '900M' 'max_memory_restart':
(process.env.MAX_MEMORY / process.env.INSTANCES || 1) || '300M',
'NODE_ENV': 'production'
}, function() { }, function() {
pm2.disconnect(); pm2.disconnect();
}); });