Show all ENV variables used by a pm2 process — NodeJS

--

There are multiple ways of setting environment variables, such as defining it in the bash profile on the host, part of a pm2 deployment file — ecosystem.js, .env file or, any other method you might use. Having said that, knowing which environment variables are set for the current process can be challenging. Besides, if we add the fact that pm2 expects an explicit flag --update-env to the restart/reload command in order to reload environment variables, it becomes hard to be sure about the current env variables state.

Luckily, pm2 has a command that does just that. The pm2 env id will show all the environment variables loaded to the pm2 process with the specified id.

list of pm2 enviroment variables for the id 1

The id can be obtained by running the pm2 l command.

pm2 listing running processes to obtain id

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Hamza Sabljakovic
Hamza Sabljakovic

Written by Hamza Sabljakovic

Software engineer based in Stockholm, Sweden.

No responses yet

Write a response