回到顶部

阅读目录

django uwsgi 错误日志分析例子

uwsgi 启动时就报错

一般能看到:--- no python application found, check your startup logs for errors ---,基本上是配置出错了,无法正常启动 uwsgi。

有用日志信息(每次启动 uwsgi 的时候就会有启动的日志产生,如果出错了就在这块找找):

*** Operational MODE: preforking ***
failed to open python file /root/yzq/djangos/testdata/Testdata/wsgi.py
unable to load app 0 (mountpoint='') (callable not found or import error)

它说 /root/yzq/djangos/testdata/Testdata/wsgi.py 这个路径打开失败,我这里是路径写错了,少写了一级。

*** Operational MODE: preforking ***
failed to open python file /root/yzq/djangos/testdata/Testdata/wsgi.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 25141)
spawned uWSGI worker 1 (pid: 25142, cores: 1)
spawned uWSGI worker 2 (pid: 25143, cores: 1)
*** Stats server enabled on 127.0.0.1:9193 fd: 11 ***
...brutally killing workers...
worker 1 buried after 1 seconds
worker 2 buried after 1 seconds
binary reloading uWSGI...
chdir() to /root/yzq/configs
closing all non-uwsgi socket fds > 2 (max_fd = 100001)...
found fd 3 mapped to socket 0 (127.0.0.1:9092)
running /root/.virtualenvs/blog/bin/uwsgi
[uWSGI] getting INI configuration from /root/yzq/configs/testdata_uwsgi.ini
*** Starting uWSGI 2.0.17 (64bit) on [Fri Feb 15 21:31:14 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 04 April 2018 04:11:16
os: Linux-3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017
nodename: VM_2_29_centos
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root/yzq/configs
detected binary path: /root/.virtualenvs/blog/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 /root/yzq/djangos/testdata
your processes number limit is 7283
your memory page size is 4096 bytes
detected max file descriptor number: 100001
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 inherited INET address 127.0.0.1:9092 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 3.6.4 (default, Mar 16 2018, 22:27:18)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Set PythonHome to /root/.virtualenvs/testdata
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x28f9820
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 304776 bytes (297 KB) for 2 cores
*** Operational MODE: preforking ***
failed to open python file /root/yzq/djangos/testdata/Testdata/wsgi.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
gracefully (RE)spawned uWSGI master process (pid: 25141)
spawned uWSGI worker 1 (pid: 27985, cores: 1)
spawned uWSGI worker 2 (pid: 27986, cores: 1)
*** Stats server enabled on 127.0.0.1:9193 fd: 11 ***
*** Starting uWSGI 2.0.17 (64bit) on [Fri Feb 15 21:32:11 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 04 April 2018 04:11:16
os: Linux-3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017
nodename: VM_2_29_centos
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /
writing pidfile to /root/yzq/running/uwsgi_testdata.pid
detected binary path: /root/.virtualenvs/blog/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 /root/yzq/djangos/testdata
your processes number limit is 7283
your memory page size is 4096 bytes
detected max file descriptor number: 1000000
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 127.0.0.1:9092 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 3.6.4 (default, Mar 16 2018, 22:27:18)  [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Set PythonHome to /root/.virtualenvs/testdata
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x17141f0
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 304776 bytes (297 KB) for 2 cores
*** Operational MODE: preforking ***
failed to open python file /root/yzq/djangos/testdata/Testdata/wsgi.py
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 527)
spawned uWSGI worker 1 (pid: 541, cores: 1)
spawned uWSGI worker 2 (pid: 542, cores: 1)
*** Stats server enabled on 127.0.0.1:9193 fd: 11 ***
--- no python application found, check your startup logs for errors ---
[pid: 541|app: -1|req: -1/1] 193.112.40.139 () {32 vars in 365 bytes} [Fri Feb 15 21:36:07 2019] GET / => generated 21 bytes i
n 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 541|app: -1|req: -1/2] 193.112.40.139 () {32 vars in 365 bytes} [Fri Feb 15 21:36:10 2019] GET / => generated 21 bytes i
n 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

uwsgi 正常启动,访问相关视图才报错

日志里明确的得到有用信息:

django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['article/(?
P<pk>[0-9]+)/$']

路由缺少参数,我这个问题是因为缓存没更新引起的。具体情况是,django 新模板代码 拿到旧的数据结构(因为是缓存数据-旧的数据结构,缓存时长 12H)去解析导致的,只需要进入缓存,把 key 删除就可以,或者换个新 key。

[pid: 11774|app: 0|req: 420/491] 111.206.221.40 () {44 vars in 1222 bytes} [Wed Dec 25 20:06:17 2019] GET /like_get/?cur_url=http%3A%2F%2Fzhuoqun.info%2Farticle%2F215%2F&article_id=215&csrfmiddlewaretoken=DcI4hLPyMtwaL5hutjx1s5KnfUTEWcWBudwwYYk9iyHu8iI2IQQ1Ez1saXXeY3WZ => generated 242 bytes in 44 msecs (HTTP/1.1 200) 3 headers in 101 bytes (1 switches on core 2)
[pid: 11775|app: 0|req: 72/492] 111.206.221.104 () {50 vars in 1101 bytes} [Wed Dec 25 20:06:17 2019] POST /visit_web/ => generated 1342 bytes in 25 msecs (HTTP/1.1 403) 3 headers in 102 bytes (1 switches on core 3)
django.security.csrf: 2019-12-25 20:06:17,771 /root/.virtualenvs/blog/lib/python3.6/site-packages/django/middleware/csrf.py [l
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/loader_tags.py", line 72, in render
    result = block.nodelist.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/loader_tags.py", line 72, in render
    result = block.nodelist.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/library.py", line 245, in render
    return t.render(new_context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 209, in render
    return self._render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/defaulttags.py", line 216, in render
    nodelist.append(node.render_annotated(context))
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/defaulttags.py", line 322, in render
    return nodelist.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/template/defaulttags.py", line 458, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/urls/base.py", line 91, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "/root/.virtualenvs/blog/lib/python3.6/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
    raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'detail' with arguments '('',)' not found. 1 pattern(s) tried: ['article/(?
P<pk>[0-9]+)/$']
[pid: 9439|app: 0|req: 19/23] 223.166.75.193 () {46 vars in 779 bytes} [Wed Dec 25 00:57:26 2019] GET / => generated 2073 byte
s in 624 msecs (HTTP/1.1 200) 5 headers in 278 bytes (1 switches on core 2)
[pid: 9439|app: 0|req: 20/24] 124.225.47.166 () {42 vars in 781 bytes} [Wed Dec 25 00:57:28 2019] GET /favicon.ico => generate
d 0 bytes in 11 msecs (HTTP/1.1 301) 4 headers in 160 bytes (1 switches on core 3)

 


^_^
请喝咖啡 ×

文章部分资料可能来源于网络,如有侵权请告知删除。谢谢!

前一篇: js 动态修改浏览器标签的 title
下一篇: linux(centos)怎样从底部向上查看 log 文件