Environment Variables with PM2 + Infisical
Today, Infisical released docs for injecting environment variables into apps using PM2.
PM2 is a production process manager for Node.js applications. It allows you to keep your Node.js applications running, even after a system reboot, by managing the processes and automatically restarting them if they crash.
Infisical is a popular new open-source end-to-end encrypted secret manager. It helps teams keep their environment variables synced by injecting them into their apps and infrastructure.
There are a few steps to start syncing environment variables:
Add your environment variables to Infisical.
Install the Infisical CLI for your machine.
Create a (bash or js) script at the root of your app. As an example, you can create a bash script called
infisical-run.sh
containing:infisical run -- npm start
Start your app with PM2:
pm2 start
infisical-run.sh
That’s all it takes to start pulling and injecting environment variables from Infisical into your app with P2M!
With this integration, your team can now use PM2 + Infisical to start your app with the right set of environment variables at all times :)