即使我发布这个问题后会被禁止!我不得不说,人们将错误消息(例如信息)视为[emperor] unloyal bad behaving vassal found: web2py.ini throttling it...
信息丰富的内容,同时将其软件定位于企业,不应该使用键盘!
因为它不允许我们工作!
我们的文明严重依赖于软件,而我们在计算机领域的专业程度非常低
——Bjarne Stroustrup
我的Python应用程序(Flask
)运行在uWSGI
(应用程序服务器)后面,(http服务器)前面Nginx
,并打包在docker
容器中。我试图实现的是将真实 IP 地址从 http 服务器 ( Nginx
) 转发到我的应用程序服务器 ( uWSGI
)。
为此,我在 nginx 配置中指定了 headers X-Real-IP
。X-Forwarded-For
不幸的是,检查烧瓶时request.headers
我只能看到
Host
标题,其余两个丢失了。
相同的设置适用于gunicorn
,并且我的标题存在。知道如何修复它吗?
server {
listen 80;
server_name app.local;
## uWSGI setup for API
location /api {
include /etc/nginx/uwsgi_params;
uwsgi_pass unix:///var/run/app.uwsgi.sock;
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Run Code Online (Sandbox Code Playgroud) 我没有使用 uwsgitop 和 socket 获取 uwsgi 统计信息。我已经将 uwsgi 配置用于带有套接字的统计信息,当我尝试使用以下命令获取统计信息时:
uwsgitop /var/www/uwsgi/proj.socket
Run Code Online (Sandbox Code Playgroud)
它抛出错误
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Run Code Online (Sandbox Code Playgroud)
我正在使用uwsgi 版本 2.0.17.1。
这是我的 uwsgi ini 文件
[uwsgi]
# Multi Thread Support
enable-threads = true
# Django-related settings
# the base directory (full path)
chdir = /home/user/base-dir/proj-path/
# Django's wsgi file
module = proj.wsgi
# the virtualenv (full path)
home = /home/user/base-path/
# process-related settings
# master
master = true
# maximum number of worker processes
processes …
Run Code Online (Sandbox Code Playgroud) 我想运行一个类似cron的命令与python装饰器,需要是唯一的(所以如果前一个进程仍在运行,它不会启动一个新进程)与uwsgi.
看一下文档(http://uwsgi-docs.readthedocs.org/en/latest/PythonDecorators.html)我看到我可以做这样的事情
task.py
from uwsgidecorators import *
@timer(600) #every 10 minutes
def myfunction(signum):
pass
Run Code Online (Sandbox Code Playgroud)
uwsgi.ini
[uwsgi]
...
import=task
...
Run Code Online (Sandbox Code Playgroud)
但是这种方式并不像我做的那样独特(遵循文档http://uwsgi-docs.readthedocs.org/en/latest/Cron.html)
task.py
...
all_my_tasks
...
Run Code Online (Sandbox Code Playgroud)
uwsgi.ini
[uwsgi]
...
cron2 = minute=-10,unique=1 python path/to/task.py
...
Run Code Online (Sandbox Code Playgroud)
有没有办法使用uwsgi的装饰器和计时器而不是cron?