AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[uwsgi](server)

Martin Hope
dav
Asked: 2021-09-22 09:25:28 +0800 CST

centos8 nginx uwsgi套接字权限被拒绝

  • -1

我已将 uwsgi 和 nginx 配置为通过位于用户主目录中的套接字(chmod 777)工作,但 nginx 无法访问套接字(13:Permission denied in error.log)。尝试使用 777 chmod 将套接字移动到 /tmp/,但随后收到错误2: No such file or directory

2021/09/21 19:40:16 [crit] 68278#0: *17 connect() to unix:///tmp/my.sock failed (2: No such file or directory) while connecting to upstream, client: ***, server: ***, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///tmp/my.sock:", host: "****"

2021/09/21 20:10:16 [crit] 517#0: *1 connect() to unix:/home/***/.deploy/my.sock failed (13: Permission denied) while connecting to upstream, client: ***, server: ***, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/home/***/.deploy/my.sock:", host: "***"

PS selinux 禁用

nginx centos8 uwsgi
  • 1 个回答
  • 512 Views
Martin Hope
Felix
Asked: 2021-09-22 00:59:48 +0800 CST

uWSGI 中止响应,失去与 nginx 的连接

  • 1

我正在运行一个用 Python 编写的小型 Web 应用程序,在 uWSGI 中运行并通过 nginx 提供服务。有一个组件可以生成 ZIP 文件以供下载,有时可能会很大(几 GB)。经常出现nginx和uWSGI的连接断开,请求中止的情况;当浏览器超时时,nginx 会忽略截断的响应,因为它会保持连接打开,期待更多的响应数据。应用程序生成一个正确的 Content-Length 标头。

从 uWSGI 日志中:

uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 429] during GET [...]
OSError: write error
SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request [...] !!!

我已经在 uWSGI 配置中设置了socket-timeout,socket-send-timeout和socket-write-timeoutto 180,但无济于事。nginx conf 包括uwsgi_read_timeout 180s;和uwsgi_buffering off;

该效果大部分是可重现的,因为它在大多数时间都会发生,尤其是在响应较大的情况下,但从不会出现在相同的偏移量上。一遍又一遍地重复请求最终可能会导致完成。

http python nginx uwsgi
  • 1 个回答
  • 788 Views
Martin Hope
musbur
Asked: 2021-01-02 04:40:11 +0800 CST

如何在 Apache / mod_proxy_uwsgi 后面使用 UNIX 域套接字?

  • 2

在我的开发系统上,我正在使用 uwsgi 和 nginx 运行 Flask WSGI 应用程序。但是在生产服务器上我需要使用 Apache 而不是 nginx,所以我正在尝试这样做。在 nginx 中,站点的安装方式如下:

location /flaskapp { uwsgi_pass unix:/tmp/flaskapp.sock; }

它有效。在 Apache 我试过这个:

 ProxyPass /flaskapp unix:/tmp/flaskapp.sock|uwsgi://flaskapp

这在日志文件中给了我一个 503 错误:

[Fri Jan 01 13:19:45.551524 2021] [proxy:error] [pid 14167] (2)No such file or directory: AH02454: uwsgi: attempt to connect to Unix domain socket /tmp/flaskapp.sock (flaskapp) failed
[Fri Jan 01 13:19:45.551802 2021] [:error] [pid 14167] [client ::1:48950] AH10101: failed to make connection to backend: httpd-UDS:0

我启用了 mod_proxy 和 mod_proxy_uwsgi 模块。我不明白“没有这样的文件或目录”位。套接字文件显然是它应该在的位置。

当然,我停止了 nginx,然后重新启动了 Apache,以防止 nginx 保留该套接字。

ProxyPass 指令的文档没有解释管道(“|”)字符后面的部分是什么意思,所以我不知道该放什么以及为什么。

mod-proxy apache-2.4 uwsgi
  • 1 个回答
  • 723 Views
Martin Hope
posop
Asked: 2020-07-22 23:01:54 +0800 CST

由 nginx uwsgi 服务的烧瓶应用程序返回 502

  • 0

我无法连接到由 nginx 和 uwsgi 提供的烧瓶应用程序(searx 搜索引擎)。

我的网络服务器显示“502 Bad Gateway nginx”

这是我的 nginx 错误:错误日志:/var/log/nginx/error.log

[crit] 2688#2688: *4 connect() to unix:/run/uwsgi/app/searx/socket.sock failed 
(2: No such file or directory) while connecting to upstream,
client: 216.186.XXX.XXX, server searx.mysite.com, 
request: "GET / HTTP/1.1", 
upstream: "uwsgi://unix:/run/uwsgi/app/searx/socket.sock:", 
host: "searx.mysite.com"

所以我可以看到socket.sock和上游不一样。

这是我的 nginx.conf

user http;
worker_processes auto;
worker_cpu_affinity auto;

events {
    multi_accept on;
    worker_connections 1024;
}

http {
    charset utf-8;
    sendfile on;
    tcp-nopush on;
    tcp_nodelay on;
    server_tokens off;
    log_not_found off;
    types_hash_max_size 4096;
    client_max_body_size 16M;

    include mime.types;
    default_type application/octet-stream;

    keepalive_timeout 65;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log warn;

    include /etc/nginx/sites-enabled/*;
}

这是我的 searx.conf,我指定 .sock 文件所在的唯一位置:

/etc/nginx/sites-enabled/searx.conf

server {
    listen 80;
    server_name searx.mysite.com;
    
    location / {
        include uwsgi_params;
        uwsgi_pass unix:/run/uwsgi/app/searx/socket.sock;
    }
    
    root /usr/local/searx/searx-src/searx;
    location /static { }
}

当我查看我的套接字文件夹时,那里没有文件......

ls -alh /run/uwsgi/app/searx/
total 0
drwxr-xr-x 2 searx searx 40 Jul 22 05:02 .
drwxr-xr-x 3 root  root  60 Jul 22 05:02 ..

我用来运行 uwsgi 的命令是:

exec chpst -u http env LC_ALL=en_US.UTF-8 /usr/bin/uwsgi --master --die-on-term --emperor /etc/uwsgi/sites

我用来运行 nginx 的命令:

exec chpst -u root /usr/bin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"

这是我的 searx uwsgi 文件

/etc/uwsgi/sites/searx.ini

[uwsgi]
project = searx
uid = searx
gid = searx
base = /usr/local/searx/searx-src

chdir = %(base)/%(project)
env = SEARX_SETTINGS_PATH=/etc/searx/settings.yml

disable-logging = false
workers = 2

chmod-socket = 666
vacuum = true

single-interpreter = true
master = true
plugin = python
lazy-apps = true
enable-threads = true

module = searx.webapp

route-run = fixpathinfo:

virtualenv = /usr/local/searx/searx-pyenv
pythonpath = %(base)

# NOTE: if I add or delete the next line there is no difference in output
socket = /run/uwsgi/app/searx/socket.sock

更多挖掘:在我设置的 searx.ini中,在日志disable-logging = false中找到了这个:/var/log/uwsgi/current

thunder lock: disabled (you can enable it with --thunder-lock
bind(): Permission denied [core/socket.c line 230]
Wed July 22 15:05:31 2020 - [emperor] curse the uwsgi instance searx.ini (pid: 3320)
Wed July 22 15:05:31 2020 - [emperor] removed uwsgi instance searx.ini

所以我的 searx.ini 或者我怎么称呼它肯定有问题?

我不确定您可能需要哪些其他信息,但很高兴根据需要更新问题。我已经在这几天了,所以我非常感谢你能提供的任何帮助。

nginx uwsgi flask
  • 1 个回答
  • 1804 Views
Martin Hope
Nenad Bulatović
Asked: 2018-12-01 04:26:11 +0800 CST

uwsgi 无法在 Ubuntu Ubuntu 18.04.1 LTS 上启动

  • 2

我正在关注这个Askbot 安装教程,它一直运行到最后,当我无法启动 uWsgi 时:

sudo systemctl restart uwsgi

我得到的错误是:

sudo systemctl restart uwsgi
Job for uwsgi.service failed because the control process exited with error code.
See "systemctl status uwsgi.service" and "journalctl -xe" for details.

ubuntu@ip-XX-XX-XX-XX:~$ systemctl status uwsgi.service
● uwsgi.service - LSB: Start/stop uWSGI server instance(s)
   Loaded: loaded (/etc/init.d/uwsgi; generated)
   Active: failed (Result: exit-code) since Fri 2018-11-30 12:15:45 UTC; 44s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 19678 ExecStop=/etc/init.d/uwsgi stop (code=exited, status=0/SUCCESS)
  Process: 7999 ExecStart=/etc/init.d/uwsgi start (code=exited, status=1/FAILURE)

Nov 30 12:15:45 ip-XX-XX-XX-XX systemd[1]: Starting LSB: Start/stop uWSGI server instance(s)...
Nov 30 12:15:45 ip-XX-XX-XX-XX uwsgi[7999]:  * Starting app server(s) uwsgi
Nov 30 12:15:45 ip-XX-XX-XX-XX uwsgi[7999]:    ...fail!
Nov 30 12:15:45 ip-XX-XX-XX-XX systemd[1]: uwsgi.service: Control process exited, code=exited status=1
Nov 30 12:15:45 ip-XX-XX-XX-XX systemd[1]: uwsgi.service: Failed with result 'exit-code'.
Nov 30 12:15:45 ip-XX-XX-XX-XX systemd[1]: Failed to start LSB: Start/stop uWSGI server instance(s).


ubuntu@ip-XX-XX-XX-XX:~$ journalctl -xe

-- Subject: Unit uwsgi.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit uwsgi.service has begun starting up.
Nov 30 12:22:53 ip-XX-XX-XX-XX uwsgi[9701]:  * Starting app server(s) uwsgi
Nov 30 12:22:53 ip-XX-XX-XX-XX uwsgi[9701]:    ...fail!
Nov 30 12:22:53 ip-XX-XX-XX-XX systemd[1]: uwsgi.service: Control process exited, code=exited status=1
Nov 30 12:22:53 ip-XX-XX-XX-XX systemd[1]: uwsgi.service: Failed with result 'exit-code'.
Nov 30 12:22:53 ip-XX-XX-XX-XX systemd[1]: Failed to start LSB: Start/stop uWSGI server instance(s).
-- Subject: Unit uwsgi.service has failed


(venv) askbot@ip-XX-XX-XX-XX:/srv/askbot/venv$ sudo /etc/init.d/uwsgi status
● uwsgi.service - LSB: Start/stop uWSGI server instance(s)
   Loaded: loaded (/etc/init.d/uwsgi; generated)
   Active: failed (Result: exit-code) since Fri 2018-11-30 12:41:10 UTC; 26s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 19678 ExecStop=/etc/init.d/uwsgi stop (code=exited, status=0/SUCCESS)
  Process: 12812 ExecStart=/etc/init.d/uwsgi start (code=exited, status=1/FAILURE)

Nov 30 12:41:10 ip-XX-XX-XX-XX systemd[1]: Starting LSB: Start/stop uWSGI server instance(s)...
Nov 30 12:41:10 ip-XX-XX-XX-XX uwsgi[12812]:  * Starting app server(s) uwsgi
Nov 30 12:41:10 ip-XX-XX-XX-XX uwsgi[12812]:    ...fail!
Nov 30 12:41:10 ip-XX-XX-XX-XX systemd[1]: uwsgi.service: Control process exited, code=exited status=1
Nov 30 12:41:10 ip-XX-XX-XX-XX systemd[1]: uwsgi.service: Failed with result 'exit-code'.
Nov 30 12:41:10 ip-XX-XX-XX-XX systemd[1]: Failed to start LSB: Start/stop uWSGI server instance(s).
(venv) askbot@ip-XX-XX-XX-XX:/srv/askbot/venv$
uwsgi
  • 1 个回答
  • 5511 Views
Martin Hope
Puchatek
Asked: 2017-09-12 21:50:59 +0800 CST

systemctl start 有效,但 systemctl enable 因 realpath() 错误而失败

  • 0

我正在尝试在 Ubuntu 16.04 上设置一个名为projectVagrant 的简单 uwsgi 服务。它应该启动一个 Nginx 可以与之对话的简单 Flask 应用程序。

我可以在运行时使服务正常工作 systemctl start project,但在启动后无法使服务运行systemctl enable project。

这是我的project.ini:

[uwsgi]
module = wsgi:app

master = true
processes = 5

socket = /tmp/project.sock
uid = ubuntu
gid = ubuntu

chmod-socket = 666
vacuum = true

die-on-term = true

logto = /tmp/project.log

这是我的/etc/systemd/system/project.service:

[Unit]
Description=uWSGI instance to serve project
After=network.target

[Service]
User=vagrant
Group=vagrant
WorkingDirectory=/home/vagrant/flask_trial
Environment="PATH=.:/home/vagrant/bin:/home/vagrant/.local/bin:/home/vagrant/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini /home/vagrant/flask_trial/project.ini

[Install]
WantedBy=multi-user.target

启动后运行systemctl status project产生:

Sep 12 05:26:08 vagrant systemd[1]: Started uWSGI instance to serve project.
Sep 12 05:26:09 vagrant systemd[1]: project.service: Main process exited, code=exited, status=1/FAILURE
Sep 12 05:26:09 vagrant systemd[1]: project.service: Unit entered failed state.
Sep 12 05:26:09 vagrant systemd[1]: project.service: Failed with result 'exit-code'.

运行journalctl | grep project产量:

Sep 12 05:26:08 vagrant systemd[1]: Started uWSGI instance to serve project.
Sep 12 05:26:09 vagrant uwsgi[1123]: realpath() of /home/vagrant/flask_trial/project.ini failed: No such file or directory [core/utils.c line 3618]
Sep 12 05:26:09 vagrant systemd[1]: project.service: Main process exited, code=exited, status=1/FAILURE
Sep 12 05:26:09 vagrant systemd[1]: project.service: Unit entered failed state.
Sep 12 05:26:09 vagrant systemd[1]: project.service: Failed with result 'exit-code'.

我怀疑两个问题之一:文件权限,因为谷歌显示人们经常难以获得这些权利,或者路径,因为 realpath() 失败。

许可flask_trial是

drwxrwxr-x 1 vagrant vagrant 272 Sep 12 04:50 flask_trial

对于其中的所有文件:

-rwxrwxr-x 1 vagrant vagrant 185 Sep 11 02:59 main.py
-rwxrwxr-x 1 vagrant vagrant 189 Sep 12 04:50 project.ini
-rwxrwxr-x 1 vagrant vagrant  70 Sep 11 03:47 wsgi.py

我启用服务 with servicectl enable project, without sudo,所以用户应该是vagrant。

怀疑路径问题,因为看起来 uwsgi 找不到 project.ini,我尝试将 ExecStart 修改为以下任何一个:

ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini /home/vagrant/flask_trial/project.ini
ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini project.ini
ExecStart=/home/vagrant/anaconda3/bin/uwsgi --ini ./project.ini

以上似乎都不适用于启动,但都适用于systemctl start. 真的在这里迷路了,希望能得到一些评论。

uwsgi
  • 1 个回答
  • 1218 Views
Martin Hope
Jasmine
Asked: 2017-03-14 01:19:33 +0800 CST

在 Nginx server_name 中使用 IP 地址我 Django

  • 0

我正在使用 django、uwsgi 和 nginx。我已经尝试过使用 nginx 和 django 文档来提供静态文件。我的conf文件是:

http {


upstream django {
    server 127.0.0.1:8000;
}

server {
    listen 80;
    server_name 192.xx.xx.x;

    root /path/to/project/;


    location /static/  {
        alias /path/to/static/;
    }

    location / {
        include /etc/nginx/uwsgi_params;
        uwsgi_pass django;

        uwsgi_param Host $host;
        uwsgi_param X-Real-IP $remote_addr;
        uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
        uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
    }
}
}

我的配置文件是真的吗?我可以在server_name部分中使用 IP 地址吗?(IP地址是我的机器IP)

django python nginx uwsgi
  • 2 个回答
  • 2969 Views
Martin Hope
SteveL
Asked: 2017-02-03 02:36:23 +0800 CST

压缩 uwsgi-nginx 和 nginx 负载均衡器之间的流量

  • 1

我有 7 个 nginx 网络服务器运行一个 python 应用程序并通过 uwsgi 和一个套接字文件将其提供给 nginx,在这 7 个网络服务器前面有一个 nginx 负载均衡器,从负载均衡器向公众发出的流量被正确压缩,导致只有~20Mbps的传出流量,但是由于某种原因从网络服务器和负载均衡器出来的流量没有被压缩,导致负载均衡器的总传入流量(来自服务器子网接口)为400Mbps,每个Web 服务器可以承受大约 70Mbps 的传出流量。

是否应该像在 laod 平衡器上启用 gzip 压缩一样启用它(它在哪里工作)?这里有一些不同的配置吗?

网络服务器 nginx.conf:

user xxx;
worker_rlimit_nofile 99999;
worker_processes  16;

events {
    worker_connections 65535;
}
http {
    proxy_cache_path  /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
    proxy_temp_path /tmp;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 620;
        keepalive_requests 20000;
#   types_hash_max_size 2048;
    client_max_body_size 200m;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    #ssl_prefer_server_ciphers on;

    proxy_buffer_size   128k; 
    proxy_buffers   16 256k;
    proxy_busy_buffers_size   256k;
    uwsgi_buffer_size 128k;
    uwsgi_buffers 16 256k;
    uwsgi_busy_buffers_size 256k;
#   uwsgi_param UWSGI_SCHEME https;
#   uwsgi_param HTTPS on;

    #log info
    log_format  main  '[$time_local] - $remote_addr - $request_time - $remote_user - $upstream_addr - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $http_cookie';
    log_format  body  '[$time_local] - $remote_addr - $request_time - $remote_user - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $request_body $http_cookie';

    access_log off;
    #access_log /home/xxx/log/ng_access.log;
    error_log /home/xxx/log/ng_error.log;

    gzip on;
    gzip_disable "msie6";
        gzip_comp_level 4;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    open_file_cache          max=8000 inactive=60s;
    open_file_cache_valid    120s;
    open_file_cache_min_uses 2;
    open_file_cache_errors   off;
    #uwsgi_buffering  off;

    #the cdn server, listening on port 83
    include /etc/nginx/conf.d/cdn.conf;

    #the xxx app, listening on port 81
    include /etc/nginx/conf.d/xxx.conf;

    #the dealers app, listening on port 82
    include /etc/nginx/conf.d/dealers.conf;

    #a fallback server listening on port 80, it acts as a local "load balancer" in case that we need to use this server without
    #a load balancer
    include /etc/nginx/conflb.d/http_upstreams.conf;
    include /etc/nginx/conflb.d/xxx.conf;
    include /etc/nginx/conflb.d/dealers.conf;
    include /etc/nginx/conflb.d/es.conf;
    include /etc/nginx/conflb.d/db.conf;

}

负载均衡器 nginx.conf:

user nginx;
worker_rlimit_nofile 99999;
worker_processes  15;
pid /run/nginx.pid;
events {
    worker_connections  65535;
}
http {

    include /etc/nginx/conf.d/http_upstreams.conf;

        sendfile        on;
        proxy_busy_buffers_size 128k;
        proxy_buffer_size 64k;
        proxy_buffers 4 64k;
        #proxy_max_temp_file_size 0;
        keepalive_timeout  620;
        gzip  on;
        gzip_comp_level 4;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
        include       mime.types;
        default_type  application/octet-stream;
    client_max_body_size 200m;
    #log info
    log_format  main  '[$time_local] - $remote_addr - $request_time - $remote_user - $upstream_addr - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $http_cookie';
    log_format  body  '[$time_local] - $remote_addr - $request_time - $remote_user - "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for" $http_host $request_body $http_cookie';

        access_log  /var/log/nginx/access.log  main;

    real_ip_header CF-Connecting-IP;


        include /etc/nginx/conf.d/db1.conf;
    include /etc/nginx/conf.d/db2.conf;   
        include /etc/nginx/conf.d/es.conf;
    include /etc/nginx/conf.d/st.conf;
    include /etc/nginx/conf.d/xxx.conf;
    include /etc/nginx/conf.d/dealers.conf;

    #catch all server
    server {
        listen 80 default_server;
        rewrite ^(.*) http://www.xxx.gr$1 permanent;
    }
}
load-balancing nginx uwsgi
  • 1 个回答
  • 658 Views
Martin Hope
pedrotorres
Asked: 2016-12-24 03:11:45 +0800 CST

Apache , uwsgi , django 查找时间

  • 0

我将我的设置托管在 AWS EC2 上,在我的 ubuntu 机器上,运行带有 uwsgi 和 apache 的 django 服务器。我一直试图弄清楚为什么 dev env VS local env 有如此不同的性能。使用本地服务器,我在 80 毫秒内返回我的 index.html 页面,而在开发中它几乎需要 1 秒。我实现了 django-debug-toolbar,CPU 时间为 300 毫秒,但 chrome 表示加载时间为 1.3 秒(等待(TTFB))。另一个很大的区别是,当我打开带有 URL 的页面时,它需要 1 秒,但如果我输入服务器的 IP,它会在 300 毫秒内加载。

我已经尝试了所有方法,但无法弄清楚加载差异的原因。

我的 apache 虚拟主机:

 <VirtualHost *:80>
            <Location />
                    Options FollowSymLinks Indexes
                    SetHandler uwsgi-handler
                    uWSGISocket 127.0.0.1:3031
            </Location>
    </VirtualHost>

uWsgi 配置:

[uwsgi]
socket = 127.0.0.1:3031
chdir = /home/ubuntu/production/<mysite>
processes = 4
threads = 2
wsgi-file=<mysite/project>/wsgi.py
virtualenv=/home/ubuntu/production
venv = /home/ubuntu/production

buffer-size=32768
django apache-2.4 uwsgi
  • 1 个回答
  • 281 Views
Martin Hope
krypto07
Asked: 2016-12-08 06:41:15 +0800 CST

设置 Django + nginx + uwsgi + supervisord:/r​​un 与 /tmp 中的套接字之间的区别

  • 1

我正在尝试使用 uWSGI Emperor 和 nginx 在同一台机器上设置 2 个 Django Web 应用程序,并让 supervisord 管理 Emperor 进程的启动和重新启动。在互联网上进行大量搜索后,我终于设法获得了有效的部署。然而,在所有拉扯头发的过程中,我发现了一些奇怪的东西,如果有人能向我解释为什么会发生这种情况,我将不胜感激。

所以我以 root 身份在帝王模式下运行我的 uWSGI 进程。vassal ini 配置文件负责删除我的 uid 的权限并创建一个由我的用户拥有的套接字文件,组为 www-data(以便 nginx 可以写入它)和权限 660。这是一个示例 vassal 配置:

[uwsgi]
uid = xxxx

chdir = %(project_dir)/%(project)
home = %(venv_base)/%(venv)
module = %(project).wsgi:application

master = true
processes = 4

socket = /tmp/%(project).sock
chown-socket = %(uid):www-data
chmod-socket = 660
stats = /tmp/%(project)_stat.sock
logto = %(project_dir)/logs/uwsgi.log
# Cleans up when the process is killed (includes deleting the socket file)
vacuum = true

这工作得很好,但是如果我尝试在 /run 而不是 /tmp 中创建套接字,我开始收到套接字 bind() 调用的权限被拒绝错误。使用适当的所有权和权限可以很好地创建套接字,但 vassal 无法在其上调用 bind() 或 unlink()。为什么会这样?/tmp 和 /run 有什么区别,我应该什么时候使用它们?任何帮助或指示将不胜感激。

编辑:我刚刚尝试将套接字的权限设置为 777 并且 uwsgi 仍然给我一个权限被拒绝错误:(

nginx ubuntu-16.04 uwsgi supervisord
  • 1 个回答
  • 964 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve