Reputation: 1798
My ecosystem.config.js file loads my environment great with this command:
pm2 start ecosystem.config.js
When I run any of these command, my environment is reloaded just fine:
pm2 reload myapp
pm2 restart myapp
pm2 reload ecosystem.config.js
pm2 restart ecosystem.config.js
Then I try to make sure I get my environment back after a reboot. If I run pm2 startup
I get this:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u me --hp /home/me
After running that command, I can reboot my machine and my application is restarted automatically. However, I am missing my environment from the ecosystem.config.js
file. Why? How do I make sure the environment from my ecosystem.config.js
environment is loaded when the machine is rebooted? Thanks.
Upvotes: 30
Views: 72194
Reputation: 13354
May be worth sharing that a file named ecosystem.js
, even if empty, needs to exist on the system in the user's home path so that pm2 can load it.
Upvotes: 4
Reputation: 1039
Dont forget to save your config! pm2 save
In case you want pm2 on startup with changed logs path:
pm2 delete all
pm2 start ecosystem.js
pm2 save
pm2 startup
Upvotes: 32
Reputation: 121
I had the same issue. After executing the command suggested by pm2 startup
, I found I had to first run pm2 delete all
, then restart using pm2 start ecosystem.config.js
. My environment is now loading as expected after rebooting.
Upvotes: 12