What values available in node.js combined create a unique ID for each process on each server in node.js? Right now, I only know how to obtain the process id.
Not sure what your requirements are but you could do a hash of (hostname + pid + timestamp):
const crypto = require('crypto');
const os = require('os');
const parts = [os.hostname(), process.pid, +(new Date)];
const hash = crypto.createHash('md5').update(parts.join(''));
hash.digest('hex'); // "56f0dec9b403c5aa19827326555d6a5b"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With