I am running PM2 on Ubuntu 16.04 and it seems that environment variables are being cached somehow. Is there an way of seeing which environment variables PM2 are using. The environment variables it can somehow see are not available in my terminal session anymore
You have to kill pm2 first.
pm2 start app.js
PM2 preserves the environment variables it read upon starting, it does not reread their values every time.
I searched for it quickly, and found this issue on github: https://github.com/Unitech/pm2/issues/83, and Unitech's answers confirm this.
In this particular comment: https://github.com/Unitech/pm2/issues/83#issuecomment-29837221
Yep this is normal in "cluster_mode". As pm2 wrap your code to his own context (and own variables) you get what was already there when launching pm2.