DarthSim / overmind

Process manager for Procfile-based applications and tmux
MIT License
2.86k stars 81 forks source link

Documentation says environment can have per process override. How? #151

Open jdchmiel opened 1 year ago

jdchmiel commented 1 year ago

Thank you for this project. I have a situation where there are many separate repos with existing .env files in them for an engineer to run them in isolation. I would like to leverage overmind to build a start up an integration testing environment where those separate repos are all running processes in the same machine and on injected env variables to change some things like ports, urls, db connections etc. There are plenty of env name conflict and port conflict, so I need to override values at a per process level, not at a global level. From the docs I was thinking this could be accomplished without adding another .env file to all of these repos one by one, but I might be totally off base there?

TLDR; Is there a way to load an .env file per process in the procfile that is only loaded for that process?

DarthSim commented 1 year ago

Hey @jdchmiel!

Though Overmind doesn't support loading .env files per process, this can be done in a somehow hacky way. overmind run doesn't do anything fancy but loads .env files and runs the provided command, so we can use this.

I believe that your Procfile looks something like this:

process1: cd /path/to/repo1 && repo1_command
process2: cd /path/to/repo2 && repo2_command
...

If these repos contain .env files, then you can run each process with overmind run so Overmind loads .env files in these repos:

process1: cd /path/to/repo1 && overmind run repo1_command
process2: cd /path/to/repo2 && overmind run repo2_command
...
jdchmiel commented 1 year ago

Hi @DarthSim Thank you for the response. The values I want to override are in the local project .env files! Those values are what a local developer has accumulated over time, so my need is to overwrite those via passing the code an env with values already set, and then they use the dotenv library to set anything not already in the env by reading from the .env file. Ideally I want overmind to NOT read the files in those local directories.

Envek commented 6 months ago

You can skip reading local .env files by setting OVERMIND_SKIP_ENV env variable to non-empty value:

process1: cd /path/to/repo1 && OVERMIND_SKIP_ENV=1 overmind run repo1_command
process2: cd /path/to/repo2 && OVERMIND_SKIP_ENV= 1overmind run repo2_command
...