2

I have the following environment variable set (trying for a 12-factor app approach):

  • PATH="/home/hope/env/bin:$PATH"

/home/hope/env/bin is the bin directory of a virtualenv, it has gunicorn and python in it, among other things. But running commands under this directory results in some funny behavior, namely:

  • python works, and sys.executable returns "/home/hope/env/bin/python" (which python says this too.)
  • gunicorn doesn't work, despite which gunicorn returning "/home/hope/env/bin/gunicorn".

Obviously to serve pages from this Django app, I need to be able to find gunicorn. I feel like I'm missing something basic, any ideas?

Edit: duh, here's supervisor's output: BACKOFF can't find command 'gunicorn'. Both python and gunicorn are 755 to the same user/group.

Brian Hicks
  • 185
  • 1
  • 8
  • What is the error exactly when you try to run gunicorn? Does the same shell session find that python binary and fail to find gunicorn? What are the permissions on the gunicorn binary? – Etan Reisner Jul 16 '13 at 12:23
  • Hah! classic mistake. I've added what you asked for, but yes: it's the same. – Brian Hicks Jul 16 '13 at 12:38
  • Oh, and the shell session fails in the same way: `gunicorn: command not found` – Brian Hicks Jul 16 '13 at 12:39
  • What does the shebang (`#!`) line in gunicorn look like? – Etan Reisner Jul 16 '13 at 12:47
  • `#!/home/hope/env/bin/python` – Brian Hicks Jul 16 '13 at 12:50
  • What happens if you run `/home/hope/env/bin/gunicorn` rather than just `gunicorn`? – Aaron Copley Jul 16 '13 at 13:14
  • It works then, but I'm afraid the fact that it doesn't work means I've gotten something major wrong in this setup. – Brian Hicks Jul 16 '13 at 13:21
  • You said `which gunicorn` from a shell finds it? What about `type -ap gunicorn`? What about both of those commands for python? Run those all in the same shell session please. – Etan Reisner Jul 16 '13 at 13:42
  • here's the funny thing, when I run this as a session (`sudo -u hope PATH="/home/hope/env/bin:$PATH" /bin/bash`) it works, finds gunicorn just fine. But when I run `sudo -u hope ... gunicorn` it fails. wat. – Brian Hicks Jul 16 '13 at 13:59
  • Your shell is what uses PATH. So `sudo -u hope PATH="/home/hope/env/bin:$PATH" /bin/bash` runs your shell with a modified $PATH whereas `sudo -u hope ... gunicorn` attempts to run gunicorn with a modified $PATH (but notably does not use that path to find gunicorn). – Etan Reisner Jul 16 '13 at 14:25
  • so... if that's the case I apparently misunderstood how to change environment variables in sudo (and gunicorn?). Any hints on how to do it properly? – Brian Hicks Jul 16 '13 at 14:41

0 Answers0