Why the .sock file not getting generated for uwsgi?
1
vote
0
answers
3963
views
I have already banged my head for last 6 hours, and nothing seems to be working for me.
I am trying to host Django through nginx and uwsgi. As per the best of my understanding and study I have configured nginx.conf and uwsgi.ini files.
nginx.conf
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server unix:/tmp/abc.sock; # for a file socket
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name localhost; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 2048M; # adjust to taste
# Django media
location /media {
alias //media; # your Django project's media files - amend as required
}
location /static {
alias //static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
include //uwsgi_params; # the uwsgi_params file you installed
uwsgi_param REMOTE_USER $remote_user;
uwsgi_param DATE_GMT $date_gmt;
uwsgi_param DATE_LOCAL $date_local;
uwsgi_param AUTH_TYPE Basic;
uwsgi_read_timeout 600s;
uwsgi_pass django;
}
}
uwsgi.ini
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /site
# Django's wsgi file
module = pjgweb.wsgi:application
# the virtualenv (full path)
home = //ENV
# process-related settings
# gid
gid = www-data
# uid
uid = www-data
# master
master = true
# maximum number of worker processes
processes = 6
# maximum number of threads for each worker process
threads = 5
# the socket (use the full path to be safe
socket = /tmp/abc.sock
# ... with appropriate permissions - may be needed
chmod-socket = 666
# clear environment on exit
vacuum = true
thread_lock = true
python_thread = true
# set the DJANGO MODULE SETTINGS
env = DJANGO_SETTINGS_MODULE=pjintegweb.settings_production
# Log to
logto = //uwsgi-app.log
# Statistics
stats = :9191
stats-http = true
- I have also created the symbolic links for both nginx.conf and uwsgi.ini.
- I did configure emperor.uwsgi.service file for systemd
[Unit]
Description=uWSGI Emperor service
After=syslog.target
[Service]
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target
When I check the nginx log file, I see below
: x.x.x.x, server: x.x.x.x, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/abc.sock:", host: "x.x.x.x"
2021/06/09 16:05:37 [crit] 1949#1949: *1 connect() to unix:/run/uwsgi/abc.sock failed (2: No such file or directory) while connecting to upstream, client: x.x.x.x, server: x.x.x.x, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/abc.sock:", host: "x.x.x.x"
2021/06/09 16:05:37 [crit] 1949#1949: *1 connect() to unix:/run/uwsgi/abc.sock failed (2: No such file or directory) while connecting to upstream, client: x.x.x.x, server: x.x.x.x, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/run/uwsgi/abc.sock:", host: "x.x.x.x"
2021/06/09 16:39:04 [alert] 2890#2890: *1 open socket #21 left in connection 3
2021/06/09 16:39:04 [alert] 2890#2890: *2 open socket #22 left in connection 4
2021/06/09 16:39:04 [alert] 2890#2890: aborting
uwsgi logs
bind(): No such file or directory [core/socket.c line 230]
*** Starting uWSGI 2.0.19.1 (64bit) on [Wed Jun 9 18:48:43 2021] ***
compiled with version: 7.5.0 on 02 June 2021 07:22:38
os: Linux-5.4.0-42-generic #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020
machine: x86_64
clock source: unix
detected number of CPU cores: 12
current working directory: /
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /
your processes number limit is 127942
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/abc.sock fd 3
Python version: 3.6.9 (default, Jan 26 2021, 15:33:00) [GCC 8.4.0]
PEP 405 virtualenv detected: //ENV
Set PythonHome to //ENV
Python main interpreter initialized at 0x55cc047f50c0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 802648 bytes (783 KB) for 30 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x55cc047f50c0 pid: 2828 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2828)
spawned uWSGI worker 1 (pid: 2833, cores: 5)
spawned uWSGI worker 2 (pid: 2834, cores: 5)
spawned uWSGI worker 3 (pid: 2835, cores: 5)
spawned uWSGI worker 4 (pid: 2840, cores: 5)
spawned uWSGI worker 5 (pid: 2845, cores: 5)
spawned uWSGI worker 6 (pid: 2850, cores: 5)
*** Stats server enabled on :9191 fd: 21 ***
SIGINT/SIGQUIT received...killing workers...
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
worker 3 buried after 1 seconds
worker 4 buried after 1 seconds
worker 5 buried after 1 seconds
worker 6 buried after 1 seconds
goodbye to uWSGI.
VACUUM: unix socket /tmp/abc.sock removed.
- When I execute the below command, I do not see any error, but the it never returns to the command line ever. Not sure why
uwsgi --ini uwsgi.ini
[uWSGI] getting INI configuration from /path_to/uwsgi.ini
It remains there for ever. I have seen multiple post on the internet, but none of them seems to helping me. Please help. Thank you.
New Logs:
--- no python application found, check your startup logs for errors ---
[pid: 9219|app: -1|req: -1/1] x.x.x.x () {38 vars in 707 bytes} [Thu Jun 10 09:26:20 2021] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
Asked by user3521180
(119 rep)
Jun 9, 2021, 02:14 PM
Last activity: Jun 10, 2021, 07:20 AM
Last activity: Jun 10, 2021, 07:20 AM