/** * basic usage of bluebird */ var Promise = require("bluebird"); //defining an async function var clAsync = function () { var P = new Promise(function (resolve, reject) { console.log('Write from function'); resolve('ok'); reject('not ok'); }); /* { "isFulfilled": true, "isRejected": false, "fulfillmentValue": "ok" } */ console.log(JSON.stringify(P, null, 2)); return P; }; console.log(JSON.stringify(clAsync, null, 2)); //undefined //executing promisified function clAsync() and adding new callback with then method clAsync() .then(function (returnedVal) { console.log('THEN 1 - fulfillmentValue= ' + returnedVal); return {one: 1, two: 'drugi'}; //returning to next then }) .then(function (returnedVal) { console.logs('THEN 2 - fulfillmentValue= ' + returnedVal.one + returnedVal.two); // return new Error('Namjerna greška'); --doesn't work throw new Error('Namjerna greška', 'someFile.js', 152); }) //catch type errors .catch(TypeError, function (e) { console.error(e.stack); // console.error(e.message); }) //catch all other errors .catch(function (e) { console.error(e.message); // console.error(e.stack); });
$ps -aux | grep node (list all node processes) sasa 914 0.5 0.5 1307568 86016 ? Ssl Aug04 343:31 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr sasa 935 0.7 0.8 11786584 132248 ? Ssl Aug04 507:59 node /home/sasa/dex8/dex8-api/starter.js sasa 938 0.4 0.4 1307036 76132 ? Ssl Aug04 292:02 node /home/sasa/regoch/regoch-www/server sasa 945 0.3 0.4 1303752 72152 ? Ssl Aug04 248:28 node /home/sasa/dex8/dex8-panel/server/index.js sasa 947 0.7 0.6 11825076 113528 ? Ssl Aug04 505:57 node /home/sasa/dex8/dex8-www/server/index.js sasa 966 0.5 0.6 11808976 98556 ? Ssl Aug04 383:13 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js sasa 980 0.8 0.5 1330216 82968 ? Ssl Aug04 526:39 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js sasa 997 0.3 0.4 1303104 71432 ? Ssl Aug04 251:13 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js sasa 1021 0.3 0.3 1297448 64404 ? Ssl Aug04 247:31 node /home/sasa/dex8/dex8-kiosk/server/index.js sasa 1065 0.6 0.6 11831312 110516 ? Ssl Aug04 422:09 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js sasa 1074 0.6 0.6 1148752 103568 ? Ssl Aug04 411:53 node /home/sasa/voovuu/voovuu-api/starter.js sasa 1136 0.7 0.9 11850660 151256 ? Ssl Aug04 477:57 node /home/sasa/voovuu/voovuu-pub/server/index.js sasa 1148 0.4 0.4 11794644 78416 ? Ssl Aug04 274:23 node /home/sasa/@mikosoft/dodo-examples/server/index.js sasa 1197 0.3 0.4 1102444 65920 ? Ssl Aug04 256:01 node /home/sasa/dex8/dex8-worker/starter.js sasa 1199 0.4 0.4 22277756 77680 ? Ssl Aug04 260:06 node /home/sasa/dex8/dex8-worker/starter.js sasa 1308 0.3 0.3 1101920 65504 ? Ssl Aug04 255:14 node /home/sasa/dex8/dex8-worker/starter.js sasa 1325 0.3 0.3 1101920 65500 ? Ssl Aug04 255:01 node /home/sasa/dex8/dex8-worker/starter.js sasa 1393 0.8 0.8 22325752 146116 ? Ssl Aug04 523:04 node /home/sasa/dex8/dex8-worker/starter.js sasa 1395 0.3 0.3 1102188 65340 ? Ssl Aug04 256:11 node /home/sasa/dex8/dex8-worker/starter.js sasa 1489 0.3 0.3 1101664 64708 ? Ssl Aug04 256:07 node /home/sasa/dex8/dex8-worker/starter.js sasa 1496 0.3 0.4 1102432 66984 ? Ssl Aug04 254:50 node /home/sasa/dex8/dex8-worker/starter.js sasa 1607 0.3 0.3 1101920 65420 ? Ssl Aug04 255:27 node /home/sasa/dex8/dex8-worker/starter.js sasa 1608 0.3 0.3 1102176 65364 ? Ssl Aug04 254:14 node /home/sasa/dex8/dex8-worker/starter.js sasa 1686 1.4 5.0 12559740 825980 ? Ssl Aug04 949:06 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index. www-data 968843 0.0 0.0 2608 592 ? S 13:49 0:00 sh -c ps -aux | grep node www-data 968845 0.0 0.0 3304 724 ? S 13:49 0:00 grep node sasa 1371685 0.4 0.5 11799868 88064 ? Ssl Aug16 210:59 node /home/sasa/mikosoft-info/solar-wind-energy/server/index.js sasa 1460918 0.4 0.3 1300136 64616 ? Ssl Aug17 209:08 node /home/sasa/sites-nodejs/oxygen-free-copper/server.js