标签: uwsgi

错误 2006:MySQL 服务器已消失

我正在使用 uWSGI 和 nginx 在 CentOS 服务器上运行 Python Pyramid 应用程序。我使用 SQLAlchemy 作为 ORM,使用 MySQLdb 作为 API,使用 MySQL 作为数据库。该网站还没有上线,所以唯一的流量是我和公司的其他一些员工。我们购买了一些数据来填充数据库,因此最大(也是最常查询)的表是 ~150,000 行。

昨天我快速连续打开了网站的四个新标签,我收到了几个 502 Bad Gateway 错误。我查看了 uWSGI 日志,发现以下内容:

sqlalchemy.exc.OperationalError: (OperationalError) (2006, 'MySQL server has gone away') 'SELECT ge...
Run Code Online (Sandbox Code Playgroud)

重要说明: 此错误不是由 MySQL 的 wait_timeout 引起的。去过也做过。

我想知道这个问题是否是由同时提供并发请求引起的。我让自己成为一个穷人的负载测试员:

for i in {1..10}; do (curl -o /dev/null http://domain.com &); done;
Run Code Online (Sandbox Code Playgroud)

果然,在这十个请求中,至少有一个会抛出 2006 错误,通常更多。有时错误会变得更奇怪,例如:

sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'table.id'"
Run Code Online (Sandbox Code Playgroud)

当该列绝对存在并且在所有其他相同请求上工作正常时。或者,这个:

sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been …
Run Code Online (Sandbox Code Playgroud)

mysql python uwsgi

8
推荐指数
1
解决办法
1万
查看次数

python 应用程序的 uwsgi.ini 配置

所以我正在试验 uWSGI 并且非常喜欢它。

我有一个关于使用它的 .ini 文件的问题。

是否可以动态计算其 .ini 配置参数的值?

例如,对于我的“uwsgi.ini”文件中的“chdir”值,我有

[uwsgi]
socket=127.0.0.1:3034
chdir=/Users/calvin/work/myproject
virtualenv=/Users/calvin/.virtualenvs/myproject
module=django.core.handlers.wsgi:WSGIHandler()
env= DJANGO_SETTINGS_MODULE=myproject.settings
master=True
pidfile=/tmp/myproject-master.pid
vacuum=True
max-requests=5000
daemonize=/var/log/uwsgi/myproject.log
Run Code Online (Sandbox Code Playgroud)

为我的“本地机器”、我的“开发/登台”服务器和我的“生产服务器”编写 3 个单独的 .ini 文件非常麻烦。更何况一个同事的本地机器的chdir价值会完全不同。

我尝试使用import os和动态os.join.path计算chdir值,但它不起作用,这是意料之中的,因为 uwsgi 没有 python 解释器?

uwsgi

7
推荐指数
1
解决办法
2万
查看次数

uWSGI 无法使用 Flask 和 Virtualenv 找到“应用程序”

使用 uWSGI 来提供一个简单的 wsgi 应用程序(一个简单的“Hello, World”)我的配置有效,但是当我尝试运行一个 Flask 应用程序时,我在 uWSGI 的错误日志中得到了这个:

current working directory: /opt/python-env/coefficient/lib/python2.6/site-packages
writing pidfile to /var/run/uwsgi.pid
detected binary path: /opt/uwsgi/uwsgi
setuid() to 497
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)  [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)]
Set PythonHome to /opt/python-env/coefficient/
*** Python threads support is disabled. You can enable …
Run Code Online (Sandbox Code Playgroud)

python wsgi uwsgi

7
推荐指数
2
解决办法
4万
查看次数

导入错误:没有名为烧瓶的模块 - uwsgi 和 buildout

uWSGI 配置:

<uwsgi>
    <module>app_wsgi:app</module>
    <pythonpath>./src</pythonpath>
    <socket>/tmp/uwsgi.sock</socket>
    <pidfile>/tmp/uwsgi.pid</pidfile>
    <daemonize>uwsgi.log</daemonize>
</uwsgi>
Run Code Online (Sandbox Code Playgroud)

配置文件

[buildout]
parts = eggs uwsgi
versions = versions
include-site-packages = false

[eggs]
recipe: zc.recipe.egg:eggs
eggs =
    flask

[versions]
flask = 0.9

[uwsgi]
recipe: buildout.recipe.uwsgi
version = 1.4.3
Run Code Online (Sandbox Code Playgroud)

例外:

*** Operational MODE: single process ***
added ./src/ to pythonpath.
Traceback (most recent call last):
  File "./src/app_wsgi.py", line 1, in <module>
    from app import create_app
  File "./src/app.py", line 1, in <module>
    from flask import Flask, request
ImportError: No module named flask
unable …
Run Code Online (Sandbox Code Playgroud)

python uwsgi

7
推荐指数
0
解决办法
1439
查看次数

ubuntu + nginx + uwsgi + django 找不到 Python 应用程序

我正在尝试使用 nginx 设置我的服务器到 uwsgi 到 django 堆栈,但是我遇到了 uwsgi 部分的问题。

当我运行 uwsgi 并在命令行中传入所有参数时,它可以正常工作。我的 uwsgi 调用如下所示:

uwsgi --socket /tmp/uwsgi.sock --chdir ~/web/test.com --wsgi-file ~/web/test.com/store/wsgi.py --virtualenv ~/web/test.com/testenv --chmod-socket=666 --enable-threads
Run Code Online (Sandbox Code Playgroud)

然后我将这些参数复制到一个如下所示的 ini 文件中:

# django.ini file
[uwsgi]
master          = true 
socket          = /tmp/uwsgi.sock
chmod-socket    = 666
chdir           = /home/ubuntu/web/test.com
wsgi_file       = /home/ubuntu/web/test.com/store/wsgi.py
virtualenv      = /home/ubuntu/web/test.com/causumptionenv
vacuum          = true
enable-threads  = true
Run Code Online (Sandbox Code Playgroud)

但是,当我使用 django.ini 文件运行 uwsgi 时,我得到了这个输出。

[uWSGI] getting INI configuration from django.ini
*** Starting uWSGI 1.9.11 (64bit) on [Fri May 31 14:52:44 2013] ***
compiled …
Run Code Online (Sandbox Code Playgroud)

ubuntu nginx django uwsgi

7
推荐指数
1
解决办法
3万
查看次数

uwsgi 进程 * 线程 = 最大同时连接数?

我们使用 uwsgi 为 nginx 后面的 python 应用程序提供服务。

我可以希望同时服务的客户端连接的理论最大值等于 uwsgi 进程 * 线程吗?

我们使用服务器发送的事件,因此连接会保持很长时间。

uwsgi

7
推荐指数
1
解决办法
6950
查看次数

收到 UWSGI SIGINT/SIGQUIT

我正在尝试将 nginx 与 uwsi 一起使用。

我写了 uwsgi ini 文件并用 uwsgi --ini site.ini 测试它

一切正常。

但是,当我尝试运行该站点时,出现以下错误(来自日志文件):

*** Python threads support is disabled. You can enable it with --enable-threads$
Python main interpreter initialized at 0x1a297d0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 800360 bytes (781 KB) for 10 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1a297d0 pid: 177$
*** …
Run Code Online (Sandbox Code Playgroud)

nginx uwsgi

7
推荐指数
0
解决办法
1656
查看次数

uWSGI 不会在 Ubuntu 16.04 下以 systemd 启动

我正在将我们的临时和生产服务器从 Ubuntu 12.04 迁移到 16.04,过程中有些痛苦。我正在测试暂存时的迁移,除了让 uWSGI 在 systemd 下启动(以前在 Upstart 下运行良好)外,它大部分都在工作。这没有问题:

uwsgi --ini /etc/uwsgi/my_wsgi.ini
Run Code Online (Sandbox Code Playgroud)

但是运行以下命令不起作用(uWSGI 不会启动,但不会产生错误):

sudo systemctl start uwsgi
Run Code Online (Sandbox Code Playgroud)

我在 /etc/systemd/system/uwsgi.service 中创建了以下服务:

[Unit]
Description=uWSGI Service

[Service]
ExecStart=/usr/local/bin/uwsgi --ini /etc/uwsgi/my_wsgi.ini
Restart=always
RestartSec=5
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

和 my_wsgi.ini 有以下内容:

[uwsgi]

# Django-related settings
# the base directory (full path)
chdir           = /path/to/project/hidden
# Django's wsgi file
module          = wsgi
# process-related settings
# master
master          = true
# maximum number of worker processes
processes       = 8
# the socket …
Run Code Online (Sandbox Code Playgroud)

ubuntu uwsgi systemd ubuntu-16.04

7
推荐指数
1
解决办法
7283
查看次数

Comet with uwsgi和nginx,如何关闭输出缓冲区?

如何防止 Nginx 缓冲我的 uwsgi 应用程序的输出?对于我的彗星式应用程序,我使用的是长轮询,并且请求现在已缓冲。

我试图减小缓冲区的大小,但不允许将uwsgi_buffer_size和设为uwsgi_buffers0。也uwsgi_max_temp_file_size不起作用(尽管手册建议这样做)。

我怎样才能做到这一点?

nginx uwsgi buffer

6
推荐指数
1
解决办法
3101
查看次数

uWSGI 权限问题

我正在尝试设置一个厨师食谱,以使我的网站运行,并且一切似乎都运行良好,但uWSGI出现以下错误:

*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from app-cms.ini
removed uwsgi instance app-cms.ini
Run Code Online (Sandbox Code Playgroud)

不再说这个:

open("/var/www/app-cms/logs/uwsgi.log"): Permission denied [utils.c line 246]
Run Code Online (Sandbox Code Playgroud)

现在正在创建该日志文件,其中包含以下内容:

*** Starting uWSGI 1.0.3-debian (64bit) on [Thu Feb  6 12:00:43 2014] ***
compiled with version: 4.6.3 on 17 July 2012 02:26:54
current working directory: /etc/uwsgi/apps-enabled
writing pidfile to /var/www/ediflo-cms/run/ediflo-cms.pid
detected binary path: /usr/bin/uwsgi-core
setgid() to 33
setuid() to 33
chdir(): Permission denied [uwsgi.c line 1723]
chdir(): Permission denied [uwsgi.c line 975]
Run Code Online (Sandbox Code Playgroud)

我不确定它试图去哪里 …

python nginx chef uwsgi

6
推荐指数
1
解决办法
8842
查看次数

标签 统计

uwsgi ×10

nginx ×4

python ×4

ubuntu ×2

buffer ×1

chef ×1

django ×1

mysql ×1

systemd ×1

ubuntu-16.04 ×1

wsgi ×1