1

I'm trying to deploy a django project using gunicorn/nginx as webserserver. The project works perfectly fine when I just run this command in virtualevn:

(.zenv)randi@server:/srv/myproj$ gunicorn  --bind 127.0.0.1:8000 myproj.wsgi:application

However, when I add virtualenv activation & the above command to /etc/supervisor/conf.d/myproj.conf:

[program:myproj]
directory = /srv/myproj
user = randi
command = source /home/randi/.zenv/bin/activate  &&  gunicorn  --bind 127.0.0.1:8000  myproj.wsgi:application
autorestart=true
redirect_stderr=true

stdout_logfile = /var/log/supervisor/access.log
stderr_logfile = /var/log/supervisor/error.log

after starting the supervisor supervisorctl start all (as root), I get:

myproj: ERROR (abnormal termination)

and supervisor status gives:

myproj   FATAL      Exited too quickly (process log may have details)

There is nothing in error logs to help. I have googled in vein and this problem has tripped my for a while. So I appreciate your help to resolve it.

Jand
  • 2,527
  • 12
  • 36
  • 66

1 Answers1

0

The problem here is that source is unknown.

Try by running supervisord in the foreground (add this to your conf):

[supervisord]
nodaemon=true               

and start supervisord (if needed with the -c path-to-.conf flag and -n for no daemon).

I had this error message:

2016-07-21 18:54:16,030 INFO spawnerr: can't find command 'source'

A solution would be to modify the path directly with the environment entry, but I couldn't make it work.

environment=PATH="/path/to/venv/bin"

See Supervising virtualenv django app via supervisor

Ehvince
  • 17,274
  • 7
  • 58
  • 79