Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set up pipenv with supervisor

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)
like image 553
Ernst Avatar asked Aug 21 '18 12:08

Ernst


People also ask

How do I get started with Pipenv?

Set up a new project with PipenvOpen a console in your project directory and type pipenv install <package_name> to install a package for the project. To specify that the package is for development, use the -d flag. You can use pip syntax to denote a specific version of a package (e.g., black==13.0b1 ).

What is the difference between pip and Pipenv?

While pip can install Python packages, Pipenv is recommended as it's a higher-level tool that simplifies dependency management for common use cases. This does a user installation to prevent breaking any system-wide packages.


1 Answers

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

like image 167
argo Avatar answered Oct 08 '22 13:10

argo