sock failed (2: No such file or directory) - django + gunicorn + virtualenv + centos7

1

I am trying to deploy a Django application on CentOS7 using gunicorn and ngnix to handle the requests.

I followed an internet guide (Digital ocean) for CentOS7 (see URL below), I followed the guide as close as possible and when it is supposed that I should see the Django application, nginx throws me a 502 error.

Apparently something is wrong with gunicorn, it does not create a .sock file, I do not know how to fix this problem.

SO: CentOS 7

Python: Python 3.6 (Running Django with a virtualenv python3.6)

Django: 2.0

Gunicorn: 19 ....

nginx

SGBD: SQLite3 (I do not need MySQL or another DBMS for now)

This is the error that shows the nginx log

2018/01/07 02:15:05 [crit] 1284#0: *1 connect() to unix:/home/django/reynaldev_services/reynaldev_services.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.104, server: 192.168.1.105, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/reynaldev_services/reynaldev_services.sock:/", host: "192.168.1.105"

This is the error that shows gunicorn

I used this guide: Digital Ocean

In /etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=django
Group=nginx
WorkingDirectory=/home/django/reynaldev_services
ExecStart=/home/django/reynaldev_services/myvenv/bin/gunicorn --workers 3 --bind unix:/home/django/reynaldev_services/reynaldev_services.sock reynaldev_services.wsgi:application

[Install]
WantedBy=multi-user.target

Notes: Nginx is running smoothly

SELinux disabled

Firewall disabled

Running Django (using python manage.py runserver .....) runs without problems

Running gunicorn --bind 0.0.0.0:8000 myproject.wsgi: application I can access without problems

Running from the user django (sudo su):

  

/ home / django / reynaldev_services / myvenv / bin / gunicorn --workers 3 --bind unix: /home/django/reynaldev_services/reynaldev_services.sock reynaldev_services.wsgi: application

[root@localhost django]# /home/django/reynaldev_services/myvenv/bin/gunicorn --workers 3 --bind unix:/home/django/reynaldev_services/reynaldev_services.sock reynaldev_services.wsgi:application
[2018-01-22 11:31:12 -0600] [1720] [INFO] Starting gunicorn 19.7.1
[2018-01-22 11:31:12 -0600] [1720] [INFO] Listening at: unix:/home/django/reynaldev_services/reynaldev_services.sock (1720)
[2018-01-22 11:31:12 -0600] [1720] [INFO] Using worker: sync
[2018-01-22 11:31:12 -0600] [1724] [INFO] Booting worker with pid: 1724
[2018-01-22 11:31:12 -0600] [1724] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/django/reynaldev_services/myvenv/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
    worker.init_process()
  File "/home/django/reynaldev_services/myvenv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/home/django/reynaldev_services/myvenv/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/home/django/reynaldev_services/myvenv/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/django/reynaldev_services/myvenv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/home/django/reynaldev_services/myvenv/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/django/reynaldev_services/myvenv/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
    __import__(module)
ModuleNotFoundError: No module named 'reynaldev_services.wsgi'
[2018-01-22 11:31:12 -0600] [1724] [INFO] Worker exiting (pid: 1724)
[2018-01-22 11:31:12 -0600] [1720] [INFO] Shutting down: Master
[2018-01-22 11:31:12 -0600] [1720] [INFO] Reason: Worker failed to boot.
[root@localhost django]#
    
asked by Reynald0 07.01.2018 в 09:27
source

0 answers