Skip to content

Instantly share code, notes, and snippets.

@droganaida
Last active October 18, 2016 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save droganaida/b6cbe6331d042a2a9d724ad1606ee37b to your computer and use it in GitHub Desktop.
Save droganaida/b6cbe6331d042a2a9d724ad1606ee37b to your computer and use it in GitHub Desktop.
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