iT邦幫忙

0

flask wsgi log rotate 設定後 服務會斷 要如何修正?

  • 分享至 

  • xImage

flask wsgi log rotate 不知為何設定後 服務會斷 要修正什麼?

設定檔 /etc/systemd/system/flaskapp.service

[Unit]
Description=uWSGI server for flask
After=network.target

[Service]
User=flask
Group=flask
WorkingDirectory=/home/flask/app/message
Environment="PATH=/home/flask/app/message/env/bin"
ExecStart=/home/flask/app/message/env/bin/uwsgi --ini wsgi.ini

[Install]
WantedBy=multi-user.target

服務起來

● flaskapp.service - uWSGI server for flask
   Loaded: loaded (/etc/systemd/system/flaskapp.service; enabled; vendor preset: disabled)
   Active: deactivating (stop-sigterm) since Tue 2023-05-09 10:43:26 CST; 1s ago
  Process: 127433 ExecStart=/home/flask/app/message/env/bin/uwsgi --ini wsgi.ini (code=exited, status=0/SUCCESS)
 Main PID: 127433 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/flaskapp.service
           └─127436 /home/flask/app/message/env/bin/uwsgi --ini wsgi.ini

May 09 10:43:26 mg3 systemd[1]: Started uWSGI server for flask.
May 09 10:43:26 mg3 uwsgi[127433]: [uWSGI] getting INI configuration from wsgi.ini

過一段時間 flaskapp.service entered failed state

● flaskapp.service - uWSGI server for flask
   Loaded: loaded (/etc/systemd/system/flaskapp.service; enabled; vendor preset: disabled)
   Active: failed (Result: timeout) since Tue 2023-05-09 10:44:56 CST; 8s ago
  Process: 127433 ExecStart=/home/flask/app/message/env/bin/uwsgi --ini wsgi.ini (code=exited, status=0/SUCCESS)
 Main PID: 127433 (code=exited, status=0/SUCCESS)

May 09 10:43:26 mg3 systemd[1]: Started uWSGI server for flask.
May 09 10:43:26 mg3 uwsgi[127433]: [uWSGI] getting INI configuration from wsgi.ini
May 09 10:44:56 mg3 systemd[1]: flaskapp.service stop-sigterm timed out. Killing.
May 09 10:44:56 mg3 systemd[1]: Unit flaskapp.service entered failed state.
May 09 10:44:56 mg3 systemd[1]: flaskapp.service failed.

wsgi.ini

[uwsgi]
module = wsgi
uid = flask
master = true
workers = 8
threads = 8
processes = 4
max-requests = 100000
buffer-size = 65535
enable-threads = false
single-interpreter = true
socket = 127.0.0.1:9999
chmod-socket = 660
vacuum = true
log-reopen = true
daemonize = /var/log/uwsgi/uwsgi-@(exec:///usr/bin/date +%%Y-%%m-%%d).log
die-on-term = true
stats = /var/log/uwsgi/stats.socket

wsgi.ini 改成 這樣可以正常但是 無法 log rotate按天切割日誌

[uwsgi]
module = wsgi
uid = flask
master = true
workers = 8
threads = 8
processes = 4
max-requests = 100000
buffer-size = 65535
enable-threads = false
single-interpreter = true
socket = 127.0.0.1:9999
chmod-socket = 660
vacuum = true
logto = /var/log/uwsgi/message.log
die-on-term = true
froce iT邦大師 1 級 ‧ 2023-05-09 13:24:37 檢舉
https://blog.zengrong.net/post/flask-uwsgi-logging-rotate/
可能你用到不支持 logreopen 的 loger了
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答