簡體   English   中英

uwsgi 使用 nginx,systemd 皇帝不使用相同的配置和設置

[英]uwsgi working with nginx, systemd emperor not working with same configs and setup

這里的問題是一切都已配置,並且運行沒有錯誤,但我不知道為什么它不起作用。 正如您將看到的,我沒有收到任何應用程序無法加載錯誤,我根本沒有收到任何錯誤,實際上這是我自開始以來最完整的沒有錯誤的錯誤。 然而,500 響應。 正如我將解釋的那樣,這里有很多內容是為了完整性。 如果我把皇帝從組合中去掉,它就可以了,就好了。

我一直在嘗試部署一個開源燒瓶應用程序 ceph-dash 以通過 uwsgi/nginx 進行監控。 盡管很痛苦,但我最終還是成功了。 我寫了一篇關於我成功的要點https://gist.github.com/Liighiche/a6aec14166d62b4f8f013415a2c1f757

然而,由於沒有守護進程管理和類似的東西,我認為最好通過使用 uwsgiEmperor 來添加我所做的事情,我按照本指南寫了這封信https://chriswarrick.com/blog/2016/02/10/部署-python-web-apps-with-nginx-and-uwsgi-emperor/

我在 Centos 7 上。我已經成功地運行並測試了這個實現上的應用程序,正如你在 gist 中看到的那樣,我實際上是在探索如何在不同的場景下配置 uwsgi。

然而,隨着 wsgi 及其所有配置文件的皇帝實現。 我收到 500 響應內部服務器錯誤。 我認為這與 nginx 和皇帝或皇帝本身之間的交接有關。 當我停止 uwsgi 服務時,我得到 502。所以 nginx 至少可以看到套接字文件。

WSGI 服務器啟動日志,全綠

*** Starting uWSGI 2.0.13.1 (64bit) on [Thu Sep  1 11:16:24 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 02 August 2016 21:07:54
os: Linux-3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016
nodename: prdceph-mon00
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /etc/uwsgi.d
detected binary path: /usr/sbin/uwsgi
chdir() to /etc/nginx/sites-enabled/ceph-dash
your processes number limit is 7282
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 /var/run/uwsgi/ceph-dash.sock fd 6
Python version: 2.7.5 (default, Aug 18 2016, 15:58:25)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]
Python main interpreter initialized at 0xee1030
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 363840 bytes (355 KB) for 4 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xee1030 pid: 3236 (default app)
mountpoint  already configured. skip.
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3236)
spawned uWSGI worker 1 (pid: 3241, cores: 1)
spawned uWSGI worker 2 (pid: 3242, cores: 1)
spawned uWSGI worker 3 (pid: 3243, cores: 1)
spawned uWSGI worker 4 (pid: 3244, cores: 1)
[pid: 3243|app: 0|req: 1/1] 127.0.0.1 () {34 vars in 429 bytes} [Thu Sep  1 11:17:31 2016] GET / => generated 291 bytes in 77 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)
announcing my loyalty to the Emperor...

WSGI 服務啟動日志,全綠

 uwsgi.service - uWSGI Emperor Service
   Loaded: loaded (/usr/lib/systemd/system/uwsgi.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2016-09-01 11:16:24 BST; 2s ago
  Process: 3231 ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi (code=exited, status=0/SUCCESS)
  Process: 3229 ExecStartPre=/bin/mkdir -p /run/uwsgi (code=exited, status=0/SUCCESS)
 Main PID: 3234 (uwsgi)
   Status: "The Emperor is governing 1 vassals"
   CGroup: /system.slice/uwsgi.service
           ├─3234 /usr/sbin/uwsgi --ini /etc/uwsgi.ini
           ├─3235 /usr/sbin/uwsgi --ini /etc/uwsgi.ini
           ├─3236 /usr/sbin/uwsgi --ini cephdash.ini
           ├─3241 /usr/sbin/uwsgi --ini cephdash.ini
           ├─3242 /usr/sbin/uwsgi --ini cephdash.ini
           ├─3243 /usr/sbin/uwsgi --ini cephdash.ini
           └─3244 /usr/sbin/uwsgi --ini cephdash.ini

Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: thunder lock: disabled (you can enable it with --thunder-lock)
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: your mercy for graceful operations on workers is 60 seconds
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** Operational MODE: no-workers ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: spawned uWSGI master process (pid: 3234)
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** Stats server enabled on /run/uwsgi/stats.sock fd: 7 ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** starting uWSGI Emperor ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: *** has_emperor mode detected (fd: 7) ***
Sep 01 11:16:24 prdceph-mon00 uwsgi[3234]: [uWSGI] getting INI configuration from cephdash.ini
Sep 01 11:16:25 prdceph-mon00 uwsgi[3234]: Thu Sep  1 11:16:25 2016 - [emperor] vassal cephdash.ini has been spawned
Sep 01 11:16:25 prdceph-mon00 uwsgi[3234]: Thu Sep  1 11:16:25 2016 - [emperor] vassal cephdash.ini is ready to accept requests

WSGI 服務器響應 500

[pid: 3243|app: 0|req: 1/1] 127.0.0.1 () {34 vars in 429 bytes} [Thu Sep  1 11:17:31 2016] GET / => generated 291 bytes in 77 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)

NGINX 服務器響應 500

<ip> - - [01/Sep/2016:11:14:16 +0100] "GET / HTTP/1.1" 500 291 "http://<ip>/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" "<my ip>, <ip>"
127.0.0.1 - - [01/Sep/2016:11:17:31 +0100] "GET / HTTP/1.1" 500 291 "-" "Python-urllib/2.7" 

貓 /etc/uwsgi.ini

[uwsgi]
uid = uwsgi
gid = nginx
pidfile = /run/uwsgi/uwsgi.pid
emperor = /etc/uwsgi.d
stats = /run/uwsgi/stats.sock
#emperor-tyrant = true
cap = setgid,setuid

cat /etc/uwsgi.d/cephdash.ini(這是應用程序的 wsgi.ini 的符號鏈接)

[uwsgi]
chdir           = /etc/nginx/sites-enabled/ceph-dash
wsgi-file       = /etc/nginx/sites-enabled/ceph-dash/contrib/wsgi/cephdash.wsgi
module          = ceph-dash:app
enable-threads  = true
master          = true
processes       = 4
socket          = /var/run/uwsgi/ceph-dash.sock
chmod-socket    = 777
vacuum          = true
uid             = uwsgi
gid             = nginx
daemonize       = /tmp/ceph-dash.log
plugins         = python,logfile
logger          = file:/tmp/myappuwsgi.log

cat /etc/nginx/conf.d/cephdash.conf

upstream uwsgi {
    server unix:///var/run/uwsgi/ceph-dash.sock;
}

server {
    listen 5000;
    server_name <hostname>
    charset     utf-8;

    location / {
        uwsgi_pass  uwsgi;
        include     /etc/nginx/sites-enabled/ceph-dash/contrib/nginx/uwsgi_params; 
    }
}

我已經卸載了我通過 pip 安裝的 uwsgi。 我似乎仍然有一個/sbin/uwsgi (從/usr/sbin鏈接),它看起來是為 systemd 安裝的一個,還有一個/usr/bin/uwsgi我不知道這是怎么發生的。 我將.service文件更改為使用/usr/bin並出現相同的錯誤。 然而,來自 rpm 的二進制文件沒有安裝插件,而/usr/bin中的有。 systemd uwsgi 現在以/usr/bin/uwsgi開頭,正如您在下面看到的,二進制文件加載了所需的插件,但我收到相同的內部服務器錯誤,並且來自 systemd 和啟動記錄的相同消息沒有錯誤,沒有失敗。 才500。

rpm -ql uwsgi
/etc/uwsgi.d
/etc/uwsgi.ini
/run/uwsgi
/usr/lib/systemd/system/uwsgi.service
/usr/sbin/uwsgi
/usr/share/doc/uwsgi-2.0.13.1
/usr/share/doc/uwsgi-2.0.13.1/CHANGELOG
/usr/share/doc/uwsgi-2.0.13.1/README
/usr/share/doc/uwsgi-2.0.13.1/README.Fedora
/usr/share/licenses/uwsgi-2.0.13.1
/usr/share/licenses/uwsgi-2.0.13.1/LICENSE

python --version
Python 2.7.5
uwsgi --version
2.0.13.1
which uwsgi (POINTING TO THE RIGHT PLACE but systemd is now loading /usr/bin)
/sbin/uwsgi

uwsgi --plugins-list (DOES NOT SHOW THE PLUGINS LOADED)

*** uWSGI loaded generic plugins ***
corerouter

*** uWSGI loaded request plugins ***
100: ping
101: echo
--- end of plugins list ---

*** Starting uWSGI 2.0.13.1 (64bit) on [Thu Sep  8 09:58:40 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 02 August 2016 21:07:54
os: Linux-3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016
nodename: prdceph-mon00
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /tmp
detected binary path: /usr/sbin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7282
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)
The -s/--socket option is missing and stdin is not a socket.


/usr/bin/uwsgi --plugins-list
DOES SHOW THE PLUGINS LOADED
*** uWSGI loaded generic plugins ***
gevent
nagios
rrdtool
carbon
corerouter
fastrouter
http
ugreen
syslog
rsyslog
logsocket
router_uwsgi
router_redirect
router_basicauth
zergpool
redislog
mongodblog
router_rewrite
router_http
logfile
router_cache
rawrouter
router_static
sslrouter
cheaper_busyness
transformation_tofile
transformation_gzip
transformation_chunked
transformation_offload
router_memcached
router_redis
router_hash
router_expires
router_metrics
transformation_template
stats_pusher_socket

*** uWSGI loaded request plugins ***
0: python
17: spooler
18: symcall
100: ping
110: signal
111: cache
173: rpc
--- end of plugins list ---

*** Starting uWSGI 2.0.13.1 (64bit) on [Thu Sep  8 09:58:50 2016] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-4) on 29 August 2016 09:55:26
os: Linux-3.10.0-327.28.3.el7.x86_64 #1 SMP Thu Aug 18 19:05:49 UTC 2016
nodename: prdceph-mon00
machine: x86_64
clock source: unix
detected number of CPU cores: 2
current working directory: /tmp
detected binary path: /usr/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7282
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)
The -s/--socket option is missing and 

yum 和 pip 安裝的 uWSGI 是不同的。 Systemd 可能會使用yum安裝的一個。 當你自己通過 SSH 連接並運行 uWSGI 時,系統將默認使用pip安裝的一個。

uWSGI 版本之間的主要區別在於: yum安裝的版本缺少 python 支持,因為它往往是模塊化的。 您可以安裝它,可能通過使用yum install uwsgi-python (檢查您的分發存儲庫以獲取特定的包名稱)。 請注意,不同的python 版本需要不同的python 插件(2.7 將需要與3.5 不同的插件)並相應地調整要安裝的包名稱。

安裝 python 插件后,檢查插件名稱(對 uWSGI 可見)並調整 .ini 文件中plugins中的值。 該名稱可能與不帶uwsgi-前綴的已安裝包名稱匹配。

對我來說,我嘗試重新啟動 nginx,但它一直報錯。 我發現問題是sitesavailable 文件夾中的一個額外的.conf 文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM