greatcare / pm2-zabbix

A Node.js PM2 monitoring tool for Zabbix.
MIT License
87 stars 60 forks source link

Wrong pm2.pid path #48

Open rlio opened 3 years ago

rlio commented 3 years ago

Hi the code inside the PM2Tracker.js get the wrong pm2.pid path. Using _var PM2_HOME = process.env.HOME + '/' + (process.env.PM2HOME || '.pm2');, the code prepend the user home directory to the PM2_HOME environment variable and according to the code on node_modules/pm2/paths.js

I think can be useful modify the code like this if (process.env.PM2_HOME) PM2_HOME = process.env.PM2_HOME; else if (process.env.HOME && !process.env.HOMEPATH) PM2_HOME = p.resolve(process.env.HOME, '.pm2'); else if (process.env.HOME || process.env.HOMEPATH) PM2_HOME = p.resolve(process.env.HOMEDRIVE, process.env.HOME || process.env.HOMEPATH, '.pm2'); else { console.error('[PM2][Initialization] Environment variable HOME (Linux) or HOMEPATH (Windows) are not set!'); console.error('[PM2][Initialization] Defaulting to /etc/.pm2'); PM2_ROOT_PATH = p.resolve('/etc', '.pm2'); }