set up pipenv with supervisor

只谈情不闲聊 提交于 2019-12-06 23:47:24

问题


I want to deploy dev server but I have a problem with starting celery and gunicorn. I'm using scripts for my purposes

celery.sh

#!/bin/bash 
cd /home/dev/app
pipenv run celery -A config worker -B -l info

and start.sh for gunicorn

#!/bin/bash
cd /home/dev/app
pipenv run gunicorn config.wsgi:application -b 127.0.0.1:8005 -w 2 -t 60 \

    --env DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE \

    --env DSN=$SENTRY_DSN \

    --env DATABASE_URL=$DATABASE_URL \

    --log-file - \

    --error-logfile /home/dev/app/errors.log 

Also here is my config for supervisor

[program:back]
directory=/home/dev/app/
command=/home/dev/bin/start
user=dev
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
stopasgroup=true
killasgroup=true


[program:celery]
directory=/home/dev/app/
command=/home/dev/bin/celery
user=dev
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
stopasgroup=true
killasgroup=true

When I'm running sudo supervisorctl start celery I'm getting the following error: /home/dev/bin/celery: line 3: pipenv: command not found

Also I added the following lines as pipenv documentation says (https://pipenv.readthedocs.io/en/latest/diagnose/)

[supervisord]
environment=LC_ALL='en_US.UTF-8',LANG='en_US.UTF-8'

UPDATE

Changed my supervisor config:

[program:back]
directory=/home/dev/app/
command=pipenv run gunicorn config.wsgi:application --bind 127.0.0.1:8005
user=dev
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
stopasgroup=true
killasgroup=true


[program:celery]
directory=/home/dev/app/
command=pipenv run celery -A config:celery_app worker -B -l info
user=dev
autostart=true
autorestart=true
redirect_stderr=true
stopsignal=QUIT
stopasgroup=true
killasgroup=true

And now I'm getting an error:

back: ERROR (no such file)

回答1:


You need to give explicit path of gunicorn. Though I'm not sure about pipenv, but the error you are getting is because supervisor tries to find gunicorn in the directory. You should change your config file into something like this:

[program:back]
directory=/home/dev/app/
command=/path/to/pipenv run /path/to/gunicorn config.wsgi:application --bind 127.0.0.1:8005

Then you must restart your supervisord in order to load the settings.

sudo service supervisord reload




回答2:


in your config file. change command= to bash -c followed by the full path and file to execute this should do the trick



来源:https://stackoverflow.com/questions/51948425/set-up-pipenv-with-supervisor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!