mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
tornado: Log to files by port number.
Without an explicit port number, the `stdout_logfile` values for each port are identical. Supervisor apparently decides that it will de-conflict this by appending an arbitrary number to the end: ``` /var/log/zulip/tornado.log /var/log/zulip/tornado.log.1 /var/log/zulip/tornado.log.10 /var/log/zulip/tornado.log.2 /var/log/zulip/tornado.log.3 /var/log/zulip/tornado.log.7 /var/log/zulip/tornado.log.8 /var/log/zulip/tornado.log.9 ``` This is quite confusing, since most other files in `/var/log/zulip/` use `.1` to mean logrotate was used. Also note that these are not all sequential -- 4, 5, and 6 are mysteriously missing, though they were used in previous restarts. This can make it extremely hard to debug logs from a particular Tornado shard. Give the logfiles a consistent name, and set them up to logrotate.
This commit is contained in:
committed by
Tim Abbott
parent
efdaa58c24
commit
ff94254598
@@ -16,6 +16,8 @@
|
||||
create 644 zulip zulip
|
||||
}
|
||||
|
||||
/var/log/zulip/tornado-*.log
|
||||
/var/log/zulip/tornado.log
|
||||
/var/log/zulip/server.log
|
||||
{
|
||||
missingok
|
||||
|
||||
@@ -34,7 +34,7 @@ stopsignal=TERM ; signal used to kill process (default TERM)
|
||||
stopwaitsecs=30 ; max num secs to wait b4 SIGKILL (default 10)
|
||||
user=zulip ; setuid to this UNIX account to run the program
|
||||
redirect_stderr=true ; redirect proc stderr to stdout (default false)
|
||||
stdout_logfile=/var/log/zulip/tornado.log ; stdout log path, NONE for none; default AUTO
|
||||
stdout_logfile=/var/log/zulip/tornado-98%(process_num)02d.log ; stdout log path, NONE for none; default AUTO
|
||||
stdout_logfile_maxbytes=100MB ; max # logfile bytes b4 rotation (default 50MB)
|
||||
stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
|
||||
directory=/home/zulip/deployments/current/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from functools import lru_cache
|
||||
from typing import Any, Container, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import orjson
|
||||
import requests
|
||||
@@ -34,9 +35,11 @@ class TornadoAdapter(HTTPAdapter):
|
||||
try:
|
||||
resp = super().send(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=merged_proxies)
|
||||
except ConnectionError:
|
||||
parsed_url = urlparse(request.url)
|
||||
logfile = f"tornado-{parsed_url.port}.log" if settings.TORNADO_PROCESSES > 1 else "tornado.log"
|
||||
raise ConnectionError(
|
||||
f"Django cannot connect to Tornado server ({request.url}); "
|
||||
f"check {settings.ERROR_FILE_LOG_PATH} and tornado.log"
|
||||
f"check {settings.ERROR_FILE_LOG_PATH} and {logfile}"
|
||||
)
|
||||
resp.raise_for_status()
|
||||
return resp
|
||||
|
||||
Reference in New Issue
Block a user