Reputation:
So I've got a number of questions here, but first let me provide some background information.
I'm developing a Discord bot with Node.js and using PM2 for process management. This is the tree structure of the home directory of the VPS I'm running it on:
root@discord-bot-vps:~# tree . -L 2
.
├── bigbotupdate.sh
├── botupdate.sh
├── ecosystem.config.js
└── fcfs-bot
├── db
├── index.js
├── node_modules
├── package.json
├── package-lock.json
├── README.md
└── src
I initially started the bot with an ecosystem file, inside the fcfs-bot
directory, which houses a git repository. The ecosystem.config.js
file looked like this:
module.exports = {
apps : [{
name: 'FCFS-BOT',
script: 'index.js',
instances: 1,
autorestart: true,
watch: false,
shutdown_with_message: true,
kill_timeout : 3000,
time: true,
env: {
NODE_ENV: 'production',
FCFS_BOT_TOKEN: 'REDACTED'
},
}]
};
I've since moved the ecosystem.config.js
file into the home directory, but when starting the process with pm2 start ecosystem.config.js
from the home directory, it still works. This is counter-intuitive to me, as I would think the reference to index.js
for the script would no longer work as it's now in a sub directory relative to the ecosystem.config.js
. However, things work normally.
I tried testing some other things, including renaming ecosystem.config.js
, and then starting the process with pm2 start FCFS-BOT
. This also works, which confuses me as I was under the impression that an ecosystem file was necessary to provide environment variables to the process as described here: https://pm2.keymetrics.io/docs/usage/environment/.
pm2 start ecosystem.config.js
-- that is, is there any risk of the environment variables being "forgotten"?ecosystem.config.js
, running it once from that, and then deleting ecosystem.config.js
?Upvotes: 3
Views: 4343
Reputation: 67439
Just ran across this question while trying to find this same answer myself.
After doing a bit of poking around, I think this is kept in ~/.pm2/dump.pm2
. Editing that file shows that it appears to be JSON format, and has the collected metadata from my original ecosystem file as well as any other environment variables that were passed in before I saved the process definitions.
Upvotes: 6