1-Django - uwsgi
常见报错
bind(): Cannot assign requested address [core/socket.c line 769]
阿里云 + centos7.5 + python3.9 + django3.2 + uwsgi
首先这可能是偶然的问题,因为我之前的uwsgi.ini的配置是这样的:
[uwsgi]
# 填写crm项目的根目录
chdir=/opt/evcode/demo/
# 填写与项目同名的目录,这是个相对路径,主要就是找到其内的wsgi.py这个文件
module=demo.wsgi
# 虚拟环境的根目录,也就是工作目录
home=/opt/evcode/evenv
# uwsgi的主进程,其他的uwsgi的进程都是这个主进程的子进程,当你kill时,杀掉的也是这个master主进程
master=true
# uwsgi并发时的工作进程的数量,官网的建议是:2 * cup核数 + 1
# 由这几个进程来分摊并发请求
processes=3
# 临时使用http,实际部署时,通过nginx反向代理
#http=0.0.0.0:8566
socket=0.0.0.0:8566
# 当服务器退出时,自动删除unix socket文件和pid文件
vacuum=true
之前运行也好好,直到......某次项目失败......
通过排查发现uwsgi启动失败:
(evenv) [root@cs evcode]# /opt/evcode/evenv/bin/uwsgi --ini /opt/evcode/uwsgi.ini
[uWSGI] getting INI configuration from /opt/evcode/uwsgi.ini
*** Starting uWSGI 2.0.20 (64bit) on [Wed Nov 2 18:59:53 2022] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-44) on 28 April 2022 03:34:28
os: Linux-3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020
nodename: cs
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /opt/evcode
detected binary path: /opt/evcode/evenv/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /opt/evcode/demo/
your processes number limit is 6857
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): Cannot assign requested address [core/socket.c line 769]
经查百度,有铁子说是阿里云的网络问题,因为我uwsgi.ini
配置文件相关的配置是:
socket=0.0.0.0:8566
人家说这个0.0.0.0
或者是127.0.0.1
需要换成阿里云服务器的内网IP,开始我还不信!后来是在没招了,就抱着试一试的态度,将0.0.0.0
换成了我的阿里云服务器的内网ip,然后就好了..........
mmp,希望是个个例!