Last active
October 18, 2016 10:24
-
-
Save droganaida/b6cbe6331d042a2a9d724ad1606ee37b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.env.NODE_ENV = 'production'; | |
NODE_ENV = production node app.js | |
export NODE_ENV=production // nix системы | |
set NODE_ENV = production // windows | |
var async = require('async'); | |
async.parallel([ | |
functionOne, | |
functionTwo, | |
// functions ... | |
functionLast | |
], function(err, result){ | |
if (err){ | |
log.info('------ err ' + err); | |
next(); | |
} else { | |
next(); | |
} | |
}); | |
if (cluster.isMaster) { | |
var cpuCount = require('os').cpus().length; | |
for (var i = 0; i < cpuCount; i += 1) { | |
cluster.schedulingPolicy = cluster.SCHED_NONE; | |
cluster.fork(); | |
} | |
cluster.on('exit', function (worker) { | |
console.log('Worker ' + worker.id + ' died :('); | |
cluster.fork(); | |
}); | |
} else { YOUR APP CODE} | |
$pm2 start app.js -i max | |
node --nouse-idle-notification --expose-gc app.js | |
var gcInterval; | |
function init() { | |
gcInterval = setInterval(function() { gcDo(); }, 60000); | |
} | |
function gcDo() { | |
global.gc(); | |
clearInterval(gcInterval); | |
init(); | |
} | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment