Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Environmental variables are disregarded in exporting Foreman script #115

Open
isundaylee opened this issue Aug 13, 2014 · 2 comments
Open

Comments

@isundaylee
Copy link

In the task foreman:export, no '--env' option is passed to the foreman command. Therefore no environmental variables are present in the upstart scripts exported. For me this results in the program starting in RAILS_ENV=development. Is this an intentional design or a potential BUG?

@floehopper
Copy link
Contributor

I recently ran into this problem too. I've come up with a temporary workaround:

set :foreman_template_option, "--env #{application_home}/.env"

As @isundaylee says, it would be good to know whether it's intentional that the foreman:export task does not load the .env file.

If it is intentional, how are the environment variables in .env supposed to be loaded by the upstart scripts? I'd be happy to provide a PR once I know what the intention is.

@lazyatom
Copy link
Contributor

I don't think this is intentional; at some point, foreman itself changed and stopped inheriting environment variables.

I think as well as this fix, you may also need to re-export your foreman-generated startup scripts after changing any environment variables, otherwise the processes won't have those new variables set either. This is certainly true for upstart.

So, my fix is:

set :foreman_template_option, "--env #{application_home}/.env"
after "env:set", "foreman:export"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants