-
-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to make django-environ work with uwsgi emperor? #58
Comments
Hi @tiany don't worry about your english, mine seems worse than your ;) About your question, i'm using uwsgi too and when i touch con uwsgi file the environment variables is correctly reloaded. |
Had something similar @tiany What was happening to me was that environ was looking for the file in a different directory other than the project. This is how I fixed it. import os
environ.Env.read_env(os.path.join(os.getcwd(), ".env")) |
@gopar so your problem is when you start your project, no variable is loaded? I think mine is a little different, it can load all variables, but when i changed the env file and touch uwsgi.ini, uwsgi worker process restarted but all env variables is still the old ones. @joke2k i wrote the Env.read_env in my project settings.py, env file was putted in the project root directory. the process is like this:
from my research, I can got the env from process for now, I write a script to kill this pid, I'd want to find one grace way to do this. Thanks a lot. |
@joke2k I have the same issue with v0.4.0. It looks like logical consequence of the following design decisions:
uWSGI |
@max-arnold I will test it soon. Although I am not running in uwsgi-emperor mode, from the looks of it this should resolve the issue that I was having. |
@max-arnold I can confirm that #105 resolves this issue for me 😄 |
merged! thank you for debugging |
I am seeing this issue on 0.4.4. I looked into the changes that resulted from this pr and these fixes were reverted. When I do a uwsgi reload after changing a .env file, the new settings are not pulled in from the file. Is anyone else having this issue? |
Hi , for anyone else who runs into this problem: If you do not care about environment variables taking priority over variables in .env files, then you can fix this problem by overriding read_env() and have it always overwrite existing keys instead of using cls.ENVIRON.setdefault. This seems to work correctly for my use case, please let me know if you know of any flaws with this approach (aside from changing the expected priority behavior). |
@matteosimone How do you override |
@QasimK make a subclass of It might look something like
|
I am still experiencing a problem that looks similar to this one. We are using django-environ 0.4.5, which should have the #105 fix. The problem is: What i mean by this is, when is put But if i use The Not sure is it matters, but we have To make sure the path to I'm not sure if i'm doing something wrong, or the fix (#105) doesn't cover our case. How could i debug this further? |
@max-arnold Thanks for your speedy reply. You seem to be right, there's a revert commit: 0482931 @joke2k Maybe this ticket could be re-opened, if the fix was reverted? |
Please take a look at #225 as it should fix this properly, making django-environ use a copy of the environment instead of the os.environ mapper class. |
Please pay attention to here: |
I use this project with my django projection, deployed by uwsgi(emperor mode) + nginx, it worked well, thanks for your working, but when i touch the uwsgi config file, the env vars will not reload, for now, i can send signal 3 to the process which served my django app,, is there any good ways to make this done?
(sorry for my poor english...
The text was updated successfully, but these errors were encountered: