PM2 Ecosystem File environment variable precedence
0 reputation · 04 Apr 2021, 00:08 UTC
When establishing a repeatable development environment using an ecosystem.config.js file, PM2 allows the definition of multiple environment blocks, such as env and env_production, to manage configuration across different stages.
There is uncertainty regarding the resolution order when a specific environment is invoked via the --env flag while the host system also has predefined shell environment variables of the same name. It is unclear if the ecosystem file values strictly override the system shell or if the system environment takes precedence during the process instantiation.
Technical Constraints
- Targeting PM2 versions supporting the Ecosystem File format.
- Requirement for deterministic configuration in CI/CD pipelines.
Does the env_xxx block in the ecosystem configuration override existing system-level environment variables? In what order does PM2 resolve conflicts between the env block and the env_production block when both are present?