Multiple Environmentfile(S) for Systemd Service File

Multiple Environmentfile(S) for Systemd Service File

I'm using Celery alongside Django, and because I'm running into This Problem (Gunicorn not having access to OS environment variables) I've had to set EnvironmentFile=/etc/environment within my gunicorn.service file to access things like DJANGO_SECRET_KEY etc.

This works perfectly, no issues.

However when trying to get Celery setup, it's running into the same problem. My struggle is that celery already makes use of EnvironmentFile=/etc/conf.d/celery and I'd sort of like to keep my gunicorn and celery environment files separate...

I tried EnvironmentFile=/etc/environment /etc/conf.d/celery but of course this "Failed to load environment files"

Is it possible to load multiple environment files?
Or have one environment file "call" another"?
Or to simply load all environment files in a particular directory?

3

1 Answer

looks like according to

EnvironmentFile= ...may be specified more than once in which case all specified files are read.

So all I needed was

EnvironmentFile=/etc/environment
EnvironmentFile=/etc/conf.d/celery

Thanks to @steeldriver for the help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.