I have a really strange problem with supervisor and gunicorn. I read supervisor documentation, all the relevant blog posts, stackexchange questions but none of them solve my strange problem, and I don't even know where to look further.
My supervisor configuration:
[program:djangoapp] user = regularuser directory = /path/to/djangoapp command = /path/to/djangoapp/.venv/bin/gunicorn --debug --log-file - --log-level debug --name arlista --workers 9 --pythonpath /path/to/necessary/library/source/Python djangoapp.wsgi:application stdout_logfile = /path/to/logfolder/djangoapp.log autorestart = true redirect_stderr = true environment = GPG_PASSPHRASE="a_passhprase_with_a_comma_in_it", DJANGO_SETTINGS_MODULE="myapp.settings.production", DJANGO_SECRET_KEY="secret_key_working_fine", DJANGO_DB_ENGINE="django.db.backends.mysql", DJANGO_DB_HOST="localhost", DJANGO_DB_NAME="dbname", DJANGO_DB_USER="dbuser", DJANGO_DB_PASSWORD="dbpassword", DJANGO_MEDIA_ROOT="/path/to/djangoapp/media", DJANGO_STATIC_ROOT="/path/to/djangoapp/static_root", # a couple more environment variables here for Django
Everything seems to work fine. It can connect to the database, I can see the
myapp.settings.production file's pyc is generated so settings are loaded.
DJANGO_MEDIA_ROOT works fine, because images are served from that folder (and if I remove that setting, Django don't even start).
HOWEVER there are pages, when encrypted images got decrypted on the fly (that's why GPG_PASSHPRASE is necessary) and those give me blank images (images with zero length, so Django works, but the decryption does not). The decryption is made by
/usr/bin/gpg. The function which handles the decryption is in a package in
regularuser can read packages from that folder.
If I run the process with upstart, passing in the same environment variables with
env stanza or even reading them from file, everything is fine, images got decrypted, but not with supervisor.
I tried environment variables with single quote, no quote, pass
PYTHONPATH to gunicorn
--pythonpath or the environment option, and have still no luck. What can I do? Can it be a problem that GPG_PASSHPRASE contains a comma? (I can't change that.) What else? I really run out of ideas.