python - Gunicorn 在 Synology 任务计划程序中不起作用
问题描述
我正在尝试在我的 Synology ds214se nas 上使用 gunicorn 运行网站。当我通过 ssh(Putty) 运行 gunicorn 时,它可以完美运行,但是当我尝试使用 Synology 任务计划程序运行它时,无论我尝试什么,它似乎都无法正常工作。错误日志发现如下:
[2021-04-19 22:00:11 +0200] [15979] [DEBUG] Current configuration:
config: config.py
wsgi_app: None
bind: ['192.168.0.80:57831']
backlog: 64
workers: 1
worker_class: sync
threads: 1
worker_connections: 1000
max_requests: 0
max_requests_jitter: 0
timeout: 90
graceful_timeout: 30
keepalive: 2
limit_request_line: 4094
limit_request_fields: 100
limit_request_field_size: 8190
reload: False
reload_engine: auto
reload_extra_files: []
spew: False
check_config: False
print_config: False
preload_app: False
sendfile: None
reuse_port: False
chdir: /volume1/python/wunschzettel
daemon: False
raw_env: []
pidfile: None
worker_tmp_dir: None
user: 1024
group: 100
umask: 0
initgroups: False
tmp_upload_dir: None
secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
forwarded_allow_ips: ['127.0.0.1']
accesslog: None
disable_redirect_access_to_syslog: False
access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
errorlog: -
loglevel: debug
capture_output: False
logger_class: gunicorn.glogging.Logger
logconfig: None
logconfig_dict: {}
syslog_addr: udp://localhost:514
syslog: False
syslog_prefix: None
syslog_facility: user
enable_stdio_inheritance: False
statsd_host: None
dogstatsd_tags:
statsd_prefix:
proc_name: None
default_proc_name: wsgi:app
pythonpath: /volume1/python/wunschzettel/
paste: None
on_starting: <function OnStarting.on_starting at 0x1cf4e58>
on_reload: <function OnReload.on_reload at 0x1cf0050>
when_ready: <function WhenReady.when_ready at 0x1cf5d58>
pre_fork: <function Prefork.pre_fork at 0x1cf64c0>
post_fork: <function Postfork.post_fork at 0x1cf6cc0>
post_worker_init: <function PostWorkerInit.post_worker_init at 0x1cf7430>
worker_int: <function WorkerInt.worker_int at 0x1cf7b80>
worker_abort: <function WorkerAbort.worker_abort at 0x1cf8328>
pre_exec: <function PreExec.pre_exec at 0x1cf73d8>
pre_request: <function PreRequest.pre_request at 0x1cf91e0>
post_request: <function PostRequest.post_request at 0x1cf9920>
child_exit: <function ChildExit.child_exit at 0x1cfa118>
worker_exit: <function WorkerExit.worker_exit at 0x1cfa880>
nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x1cf9188>
on_exit: <function OnExit.on_exit at 0x1cfb878>
proxy_protocol: False
proxy_allow_ips: ['127.0.0.1']
keyfile: None
certfile: None
ssl_version: 2
cert_reqs: 0
ca_certs: None
suppress_ragged_eofs: True
do_handshake_on_connect: False
ciphers: None
raw_paste_global_conf: []
strip_header_spaces: False
[2021-04-19 22:00:11 +0200] [15979] [INFO] Starting gunicorn 20.1.0
[2021-04-19 22:00:11 +0200] [15979] [DEBUG] Arbiter booted
[2021-04-19 22:00:11 +0200] [15979] [INFO] Listening at: http://192.168.0.80:57831 (15979)
[2021-04-19 22:00:11 +0200] [15979] [INFO] Using worker: sync
[2021-04-19 22:00:11 +0200] [16002] [INFO] Booting worker with pid: 16002
[2021-04-19 22:00:11 +0200] [15979] [DEBUG] 1 workers
[2021-04-19 22:00:14 +0200] [16002] [DEBUG] GET /
[2021-04-19 22:00:14 +0200] [16002] [ERROR] Error handling request /
Traceback (most recent call last):
File "/volume1/homes/admin/.local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 136, in handle
self.handle_request(listener, req, client, addr)
File "/volume1/homes/admin/.local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 169, in handle_request
resp, environ = wsgi.create(req, client, addr,
File "/volume1/homes/admin/.local/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 183, in create
path_info = path_info.split(script_name, 1)[1]
IndexError: list index out of range
[2021-04-19 22:01:11 +0200] [16002] [DEBUG] Closing connection.
[2021-04-19 22:01:11 +0200] [16002] [DEBUG] GET /
[2021-04-19 22:01:11 +0200] [16002] [ERROR] Error handling request /
Traceback (most recent call last):
File "/volume1/homes/admin/.local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 136, in handle
self.handle_request(listener, req, client, addr)
File "/volume1/homes/admin/.local/lib/python3.8/site-packages/gunicorn/workers/sync.py", line 169, in handle_request
resp, environ = wsgi.create(req, client, addr,
File "/volume1/homes/admin/.local/lib/python3.8/site-packages/gunicorn/http/wsgi.py", line 183, in create
path_info = path_info.split(script_name, 1)[1]
IndexError: list index out of range
任务计划程序命令:
cd /volume1/python/wunschzettel
/volume1/@entware-ng/opt/bin/python3 -m gunicorn -c config.py wsgi:app
注意:我使用完全相同的命令和用户,以及 putty 和调度程序。请帮助我使用任务调度程序运行 gunicorn。
解决方案
我遇到了类似的问题并进行了故障排除。我用两行创建了一个 startfile:
export >> "/volume1/web/prod/vars.txt"
/volume1/@appstore/py3k/usr/local/bin/gunicorn -b 0.0.0.0:5010 fl002:app
然后我通过 SSH 和调度程序运行它。我发现了差异并将其隔离为:
SCRIPT_NAME="/webapi/entry.cgi"
如果我将 Script_name 设置为,""
那么我将不再出现此问题。
推荐阅读
- javascript - 为什么我的代码告诉我 .draw 不是函数?
- postgresql - 如何修复 Spring Boot Postgres 错误:在或附近出现语法错误:“)”位置:209
- wordpress - Wordpress 类别页面,分页在所有页面中显示相同的帖子
- c# - Unity 脚本 - VideoPlayer 不会暂停
- mongodb - 无法将 filebeat 输出发送到 mongodb
- android - Flutter ios 无法运行,获取小部件库异常和丢失设备连接
- ajax - 在 Wordpress 前端使用 AJAX 加载 php 文件
- java - 如何通过 RestController 创建对象的实例,而不通过 RequestBody 传递构造函数的所有字段?
- python - 如何复制熊猫行
- html - v-onclick evt.target 获取 span 内的按钮;我应该怎么办?