gpt4 book ai didi

django - 一条特定路由的 uwsgi 段错误

转载 作者:行者123 更新时间:2023-12-02 04:04:44 24 4
gpt4 key购买 nike

我的 django 应用程序在本地工作正常,但当我部署它时,它面临一条特定路线的 uswgi seg 错误。其他所有路线均正常工作。这是 View :

def bunny(request):
"""
Filter crawler, bot and real user
:param request:
:return: serve rendered page to crawler / SPA to user
"""
......some other codes ....
path = request.get_full_path_info()
if path.startswith('/news_paper'): # <<-- seg fault for this routes only in production server
news_paper = utils(unquote(path[12:]))
if news_paper[1] == 0: # if news paper is not found return default list
return render(request, 'site_list.html')
news = News.objects.filter(news_paper=news_paper[1]).order_by('-created_at')[:15]
return render(request, 'news.html', {'news': news, 'title': news_paper[0]})
elif path == '/about/':
return render(request, 'about.html')
else:
return render(request, 'site_list.html')

uWsgi 配置文件:

[uwsgi]
chdir=/home/..
home = /home/../.env
module=xyz.wsgi
master=True
process = 5
pidfile=/run/xyz.pid
socket= /run/xyz.sock
stats=/tmp/xyz.stat
vacuum=True
max-requests=500
logto = /home/../logs/xyz.log
log-maxsize = 200480
uid = prism
gid = www-data
die-on-term = true

chmod-socket = 666
chown-socket = www-data

和日志文件:

!!! uWSGI process 4668 got Segmentation Fault !!!
*** backtrace of 4668 ***
uwsgi(uwsgi_backtrace+0x2c) [0x46d0ac]
uwsgi(uwsgi_segfault+0x21) [0x46d471]
/lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f1c373b84b0]
/home/../.env/lib/python3.6/site-packages/psycopg2/.libs/./libssl-1d6df745.so.1.0.2p(ssl3_cleanup_key_block+0xb) [0x7f1c32d3fcab]
/home/../.env/lib/python3.6/site-packages/psycopg2/.libs/./libssl-1d6df745.so.1.0.2p(ssl3_clear+0x16) [0x7f1c32d3d5a6]
/home/../.env/lib/python3.6/site-packages/psycopg2/.libs/./libssl-1d6df745.so.1.0.2p(tls1_clear+0x9) [0x7f1c32d49219]
/usr/lib/x86_64-linux-gnu/libssl.so.1.1(SSL_new+0x462) [0x7f1c387a5d22]
/home../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(+0x23969) [0x7f1c32fd4969]
/home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(+0x24fc5) [0x7f1c32fd5fc5]
/home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(PQconnectPoll+0xb78) [0x7f1c32fbfba8]
/home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(+0xfa28) [0x7f1c32fc0a28]
/home/../.env/lib/python3.6/site-packages/psycopg2/.libs/libpq-3a62a61f.so.5.11(PQconnectdb+0x1f) [0x7f1c32fc341f]
/home/../.env/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so(+0x12651) [0x7f1c33214651]
/home/../.env/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so(+0x133df) [0x7f1c332153df]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x16cb06) [0x7f1c37af1b06]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x8b) [0x7f1c37aa810b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_CallFunction_SizeT+0x12c) [0x7f1c37aa9f1c]
/home/../.env/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so(+0xc1a8) [0x7f1c3320e1a8]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(PyCFunction_Call+0xa6) [0x7f1c37ae2466]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x5ae5) [0x7f1c37b37665]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(PyEval_EvalCodeEx+0x27d) [0x7f1c37b3114d]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1391aa) [0x7f1c37abe1aa]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(PyObject_Call+0x47) [0x7f1c37aa8547]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x1aca) [0x7f1c37b3364a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b5253) [0x7f1c37b3a253]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b5253) [0x7f1c37b3a253]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x11b8) [0x7f1c37b32d38]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x132c1b) [0x7f1c37ab7c1b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x13e18c) [0x7f1c37ac318c]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x16cb06) [0x7f1c37af1b06]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x8b) [0x7f1c37aa810b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4ce7) [0x7f1c37b39ce7]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyFunction_FastCallDict+0x13a) [0x7f1c37b3b83a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x10e) [0x7f1c37aa818e]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_Call_Prepend+0x61) [0x7f1c37aa8ce1]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyObject_FastCallDict+0x8b) [0x7f1c37aa810b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1710ee) [0x7f1c37af60ee]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x172285) [0x7f1c37af7285]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1aa2ac) [0x7f1c37b2f2ac]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyCFunction_FastCallDict+0x165) [0x7f1c37ae2235]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4b5b) [0x7f1c37b39b5b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4f6a) [0x7f1c37b39f6a]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(+0x1b4c3b) [0x7f1c37b39c3b]
/usr/lib/x86_64-linux-gnu/libpython3.6m.so.1.0(_PyEval_EvalFrameDefault+0x4d3) [0x7f1c37b32053]
*** end of backtrace ***
DAMN ! worker 1 (pid: 4668) died :( trying respawn ...
Respawned uWSGI worker 1 (new pid: 4709)

我正在使用最新版本的 django 和 psycopg2。

最佳答案

当针对两个不同的 openssl 版本编译 uwsgi 和 psycopg 时,会发生此错误。您有两种解决方案。

  • 禁用 django 数据库配置的 ssl

    # Database
    DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql',
    'NAME': 'mydb',
    'USER': 'myuser',
    'PASSWORD': 'mypassword',
    'HOST': 'localhost',
    'PORT': '',
    'OPTIONS': {
    'sslmode': 'disable'
    }
    }
    }
  • 从源代码而不是wheel安装psyocpg2

要从源代码安装 psyocpg2,您必须卸载以前的版本并尝试此

pip uninstall psycopg2
pip install --no-binary :all: psycopg2

关于django - 一条特定路由的 uwsgi 段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53496524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com