Async waterfall example nodejs

To avoid callback hell , a very useful tool for structuring calls in a sequence and make sure the steps pass the data to the next step.

var async = require('async');

async.waterfall(
    [
        function(callback) {
            callback(null, 'Yes', 'it');
        },
        function(arg1, arg2, callback) {
            var caption = arg1 +' and '+ arg2;
            callback(null, caption);
        },
        function(caption, callback) {
            caption += ' works!';
            callback(null, caption);
        }
    ],
    function (err, caption) {
        console.log(caption);
        // Node.js and JavaScript Rock!
    }
);

nJoy 😉

PM2 set logs to compress and expire

Referring to the github README.md https://github.com/pm2-hive/pm2-logrotate


pm2 install pm2-logrotate@2.6.0
pm2 set pm2-logrotate:compress true
pm2 set pm2-logrotate:max_size 10M
pm2 set pm2-logrotate:retain 7

pm2 conf

{
"pm2-logrotate": {
"max_size": "10M",
"retain": "7",
"compress": "true",
"dateFormat": "YYYY-MM-DD_HH-mm-ss",
"workerInterval": "30",
"rotateInterval": "0 0 * * *",
"rotateModule": true
},
"module-db": {
"pm2-logrotate": {
"uid": null,
"gid": null
}
}
}

nJoy 😉