我正在尝试使用uWSGI + Nginx搭建一个Web应用服务器,其中运行一个使用SQLAlchemy与Postgres数据库通信的Flask应用程序。
当我向Web服务器发出请求时,每隔一个响应就会出现500错误。
错误信息为:
Traceback (most recent call last):
File "/var/env/argos/lib/python3.3/site-packages/sqlalchemy/engine/base.py", line 867, in _execute_context
context)
File "/var/env/argos/lib/python3.3/site-packages/sqlalchemy/engine/default.py", line 388, in do_execute
cursor.execute(statement, parameters)
psycopg2.OperationalError: SSL error: decryption failed or bad record mac
The above exception was the direct cause of the following exception:
sqlalchemy.exc.OperationalError: (OperationalError) SSL error: decryption failed or bad record mac
这个错误是由一个简单的Flask-SQLAlchemy
方法触发的:
result = models.Event.query.get(id)
uwsgi
由 supervisor
管理,其配置如下:
[program:my_app]
command=/usr/bin/uwsgi --ini /etc/uwsgi/apps-enabled/myapp.ini --catch-exceptions
directory=/path/to/my/app
stopsignal=QUIT
autostart=true
autorestart=true
而的配置看起来像这样:
[uwsgi]
socket = /tmp/my_app.sock
logto = /var/log/my_app.log
plugins = python3
virtualenv = /path/to/my/venv
pythonpath = /path/to/my/app
wsgi-file = /path/to/my/app/application.py
callable = app
max-requests = 1000
chmod-socket = 666
chown-socket = www-data:www-data
master = true
processes = 2
no-orphans = true
log-date = true
uid = www-data
gid = www-data
我所能理解的是它与uwsgi的forking有关,但除此之外我不清楚还需要做些什么。