python - 我得到一个 [DEBUG] worker: 使用 Guncorn3 发布我的烧瓶应用程序时 SIGWINCH 忽略错误
问题描述
我用烧瓶做了一个小应用程序。我在我的 ubuntu 系统上以 python3 app.py 运行该应用程序,一切正常。我想用 gunicorn 发布应用程序,但某些功能也会出错。我查看了错误日志和 [DEBUG] worker: SIGWINCH 被忽略。我得到这个错误。错误的原因是我放了python pexpect模块
def botbaslatma():
child = pexpect.spawn('screen -S idle python3 bot_dosyalari/{}'.format(session["username"]+".py"))
i=child.expect(['Enter 2FA code: ',"Invalid password for '{}'. Enter password: ".format(session["username"]),pexpect.EOF])
if i==0:
child.sendline(Guard)
k=child.expect(['Logged on as:','Incorrect code. Enter 2FA code: ',pexpect.EOF])
if k==0:
cursor=Mysql.connection.cursor()
sorgu='UPDATE sxxxxeri SET status="Aktif" WHERE stxxxxci="{}" '.format(session["username"])
cursor.execute(sorgu)
Mysql.connection.commit()
cursor.close()
child.close()
flash("Done","success")
return redirect(url_for("xontrolxxxx",_external=True))
elif k==1:
cursor=Mysql.connection.cursor()
sorgu='UPDATE sxxxleri SET status="Bexxxyor" WHERE steaxxxici="{}" '.format(session["username"])
cursor.execute(sorgu)
Mysql.connection.commit()
cursor.close()
child.close()
flash("Wrong passwd","danger")
return redirect(url_for("xontrolxxxx",_external=True))
elif i==2:#timeout
flash("Timeout","danger")
child.close()
durdurma()
return redirect(url_for("xontrolxxxx",_external=True))
elif i==1:
child.close()
durdurma()
flash("Wrong passwd","danger")
return redirect(url_for("xontrolxxxx",_external=True))
elif i==2:
child.close()
flash("Timeout","danger")
return redirect(url_for("xontrolxxxx",_external=True))
return render_template("botxxxx.html",form=form)
#Always enters pexpect.EOF control i==2
######Gunicorn3 文件
[Unit]
Description=Gunicorn service
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/root/flaskapp
ExecStart=/usr/bin/gunicorn3 --workers 3 --bind unix:flaskapp.sock -m 007 app:app --timeout 300 --config /root/flaskapp/gunicorn.conf.py
#Gunicorn3 错误日志 *************
[2020-07-03 15:38:55 +0200] [14261] [DEBUG] Current configuration:
config: /root/flaskapp/gunicorn.conf.py
bind: ['unix:flaskapp.sock']
backlog: 2048
workers: 3
worker_class: sync
threads: 1
worker_connections: 1000
max_requests: 0
max_requests_jitter: 0
timeout: 300
graceful_timeout: 30
keepalive: 2
limit_request_line: 4094
limit_request_fields: 100
limit_request_field_size: 8190
reload: False
reload_engine: auto
spew: False
check_config: False
preload_app: False
sendfile: None
chdir: /root/flaskapp
daemon: False
raw_env: []
pidfile: None
worker_tmp_dir: None
user: 0
group: 33
umask: 7
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: /root/flaskapp/flaskapp.gunicorn.access
access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
errorlog: /root/flaskapp/flaskapp.gunicorn.error
loglevel: debug
capture_output: False
logger_class: gunicorn.glogging.Logger
logconfig: None
syslog_addr: udp://localhost:xxx
syslog: False
syslog_prefix: None
syslog_facility: user
enable_stdio_inheritance: False
statsd_host: None
statsd_prefix:
proc_name: None
default_proc_name: app:app
pythonpath: None
paste: None
on_starting: <function OnStarting.on_starting at 0x7f66cff9c048>
on_reload: <function OnReload.on_reload at 0x7f66cff9c1e0>
when_ready: <function WhenReady.when_ready at 0x7f66cff9c378>
pre_fork: <function Prefork.pre_fork at 0x7f66cff9c510>
post_fork: <function Postfork.post_fork at 0x7f66cff9c6a8>
post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f66cff9c840>
worker_int: <function WorkerInt.worker_int at 0x7f66cff9c9d8>
worker_abort: <function WorkerAbort.worker_abort at 0x7f66cff9cb70>
pre_exec: <function PreExec.pre_exec at 0x7f66cff9cd08>
pre_request: <function PreRequest.pre_request at 0x7f66cff9cea0>
post_request: <function PostRequest.post_request at 0x7f66cff9f048>
child_exit: <function ChildExit.child_exit at 0x7f66cff9f1e0>
worker_exit: <function WorkerExit.worker_exit at 0x7f66cff9f378>
nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f66cff9f510>
on_exit: <function OnExit.on_exit at 0x7f66cff9f6a8>
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: TLSv1
raw_paste_global_conf: []
[2020-07-03 15:38:55 +0200] [14261] [INFO] Starting gunicorn 19.7.1
[2020-07-03 15:38:55 +0200] [14261] [DEBUG] Arbiter booted
[2020-07-03 15:38:55 +0200] [14261] [INFO] Listening at: unix:flaskapp.sock (14261)
[2020-07-03 15:38:55 +0200] [14261] [INFO] Using worker: sync
[2020-07-03 15:38:55 +0200] [14282] [INFO] Booting worker with pid: 14282
[2020-07-03 15:38:55 +0200] [14285] [INFO] Booting worker with pid: 14285
[2020-07-03 15:38:55 +0200] [14286] [INFO] Booting worker with pid: 14286
[2020-07-03 15:38:55 +0200] [14261] [DEBUG] 3 workers
[2020-07-03 15:39:03 +0200] [14285] [DEBUG] GET /kontrolpaneli
[2020-07-03 15:39:03 +0200] [14285] [DEBUG] GET /login
[2020-07-03 15:39:13 +0200] [14282] [DEBUG] POST /login
[2020-07-03 15:39:13 +0200] [14285] [DEBUG] GET /
[2020-07-03 15:39:17 +0200] [14286] [DEBUG] GET /kontrolpaneli
[2020-07-03 15:39:19 +0200] [14285] [DEBUG] GET /botbaslatma
[2020-07-03 15:39:43 +0200] [14285] [DEBUG] POST /botbaslatma
[2020-07-03 15:39:43 +0200] [14412] [DEBUG] worker: SIGWINCH ignored. **here it is**
[2020-07-03 15:39:43 +0200] [14285] [DEBUG] GET /kontrolpaneli
解决方案
This message is harmless. The signal SIGWINCH marks that the terminal window was resized. There is no real terminal under which your app runs, so that seems normal. It is probably produced by screen.
Your code is very weird. Rather than creating a terminal through screen and driving a python command line application through pexpect, the normal approach would be to call bot_dosyalari functions directly. However, it should work.
Additionally, you shouldn't be runnning a web application as root. I guess you did that because www-data didn't have access to /root/flaskapp
, but the solution is to set the permissions right (probably moving it to e.g. /var/www/flaskapp
at the same time), not to change the webapp user.
推荐阅读
- python-3.x - Boto3 - 使用 CLI 参数将多文件上传到特定 S3 存储桶“路径”
- reactjs - 如何向 FlatList 添加新数据。(反应本机)
- javascript - 如何从 JavaScript 中的均值和标准截断正态分布中获取随机值?
- python - Rioxarray 维度缺少坐标
- python - 如何在熊猫中读取具有完整路径的csv文件
- powershell - Powershell - 替换匹配的多个正则表达式条件
- javascript - 从 Google Apps 脚本 Web 应用程序使用剪贴板 API
- php - 如何仅提取子目录名称?
- r - R中是否有代码可以更改ggboxplot中的x轴?
- python - 如何解决 TypeError:“NoneType”类型的对象没有 len()