0

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 djangoapp.log, 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 /path/to/necessary/library/source/Python. 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.

  • 1
    What version of supervisor are you using ? I have 3.0b2 and a made a little test where I can successfully set an env variable with a comma in it – Ponytech Oct 28 '14 at 13:08
  • 3.1.2, so that can't be a problem hopefully :) – kissgyorgy Nov 1 '14 at 0:17
1
+50

I probably can't help, but I'l throw out some possibilities (which might be totally wrong)

  • No whitespace before last line of command ("djangoapp..."). Possible that some step in your buildchain is concatenating this with the previous --pythonpath flag, and both are being ignored.
  • Comma in passcode (doubtful) -- Have you tried just changing the passcode? Or escaping the comma?
  • Hmm, that's interesting. There were tabulator characters in the file and no other whitespace between the environment lines. I converted every tab to space and everything seems to be working fine! Thanks! – kissgyorgy Nov 1 '14 at 0:29
  • maybe not, because I rewrote tabs and working fine... – kissgyorgy Nov 1 '14 at 0:42

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.