Running Gunicorn for chrooted nginx inside virtualenv

I can configure this setting if I start a gun or manually add guns to my installed django applications. But when I try to start firing with the system, the gun slot and the after-sales service are great, but they don’t give anything to Nginx; I get 502 bad gateways.

Nginx runs under user / group http, chroot jail. I used pythonbrew to configure virtualenvs, so the machine gun was installed in my home directory under .pythonbrew. The vitualenv directory belongs to my user and the adm group.

I am sure that somewhere there is a problem with resolution, because everything works if I start archery, but not if systemd starts it. I tried to change the user and group directives inside the gunicorn.service file, but nothing worked; if root starts the server, then I don't get any errors and 502, if my user starts it, I don't get any errors and 504.

I checked the Nginx logs and there are no errors, so I'm sure this is a weapon problem. Should I have virtualenv in the application directory? Who should be the owner of the application directory? How can I narrow the question?

/usr/lib/systemd/system/gunicorn-app.service

#!/bin/sh [Unit] Description=gunicorn-app [Service] ExecStart=/home/noel/.pythonbrew/venvs/Python-3.3.0/nlp/bin/gunicorn_django User=http Group=http Restart=always WorkingDirectory = /home/noel/.pythonbrew/venvs/Python-3.3.0/nlp/bin [Install] WantedBy=multi-user.target 

/usr/lib/systemd/system/gunicorn-app.socket

 [Unit] Description=gunicorn-app socket [Socket] ListenStream=/run/unicorn.sock ListenStream=0.0.0.0:9000 ListenStream=[::]:8000 [Install] WantedBy=sockets.target 

I understand this is a kind of stretch related question, but I'm sure I can identify the problem with a few pointers. Thanks.

Update

I'm starting to narrow it down. When I start the gun and then run ps aux|grep gunicorn , then I see two processes that start: the master and the worker. But when I start firing from the system, only one process has begun. I tried adding Type=forking to my gunicorn.services file, but then I get an error when loading the service. I thought that maybe the gun assault is not working under virtual, or Vienna is not activated?

Does anyone know what I'm doing wrong here? Maybe Pushkin doesn't work in Vienna?

+4
source share
2 answers

I know that this is not the best way, but I was able to get it working by adding a machine gun to the django INSTALLED_APPS list. Then I just created a new systemd service:

 [Unit] Description=hack way to start gunicorn and django [Service] User=http Group=http ExecStart=/srv/http/www/nlp.com/nlp/bin/python /srv/http/www/nlp.com/nlp/nlp/manage.py run_gunicorn Restart=always [Install] WantedBy=multi-user.target 

There should be a better way, but judging by the lack of answers, many people do not know that this is the best way.

0
source

I had a similar issue with OSX starting up. The problem was that I needed to let the process generate subprocesses.

Try adding Type=forking :

 [Unit] Description=gunicorn-app [Service] Type=forking 
0
source

Source: https://habr.com/ru/post/1481598/


All Articles