mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-19 11:02:45 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80c3b6490c |
+23
-7
@@ -5318,6 +5318,8 @@ class CustomFieldViewSet(PermissionsAwareDocumentCountMixin, ModelViewSet[Custom
|
|||||||
class SystemStatusView(PassUserMixin):
|
class SystemStatusView(PassUserMixin):
|
||||||
permission_classes = (IsAuthenticated,)
|
permission_classes = (IsAuthenticated,)
|
||||||
TASK_SUMMARY_DAYS = 30
|
TASK_SUMMARY_DAYS = 30
|
||||||
|
# Seconds to wait on the broker before reporting it as unreachable
|
||||||
|
BROKER_SOCKET_TIMEOUT = 5
|
||||||
|
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
if not has_system_status_permission(request.user):
|
if not has_system_status_permission(request.user):
|
||||||
@@ -5363,7 +5365,11 @@ class SystemStatusView(PassUserMixin):
|
|||||||
if redis_url_parsed.hostname is not None:
|
if redis_url_parsed.hostname is not None:
|
||||||
redis_constructed_url += f":{redis_url_parsed.port}"
|
redis_constructed_url += f":{redis_url_parsed.port}"
|
||||||
redis_error = None
|
redis_error = None
|
||||||
with Redis.from_url(url=redis_url) as client:
|
with Redis.from_url(
|
||||||
|
url=redis_url,
|
||||||
|
socket_timeout=self.BROKER_SOCKET_TIMEOUT,
|
||||||
|
socket_connect_timeout=self.BROKER_SOCKET_TIMEOUT,
|
||||||
|
) as client:
|
||||||
try:
|
try:
|
||||||
client.ping()
|
client.ping()
|
||||||
redis_status = "OK"
|
redis_status = "OK"
|
||||||
@@ -5378,12 +5384,22 @@ class SystemStatusView(PassUserMixin):
|
|||||||
celery_url = None
|
celery_url = None
|
||||||
try:
|
try:
|
||||||
celery_ping = None
|
celery_ping = None
|
||||||
for ping_attempt in range(3):
|
# Use a dedicated connection with socket timeouts. Without them a
|
||||||
celery_ping = celery_app.control.inspect().ping()
|
# stalled broker blocks this request (and its DB connection) forever
|
||||||
if celery_ping:
|
with celery_app.connection_for_read(
|
||||||
break
|
transport_options={
|
||||||
if ping_attempt < 2:
|
"socket_timeout": self.BROKER_SOCKET_TIMEOUT,
|
||||||
sleep(0.25)
|
"socket_connect_timeout": self.BROKER_SOCKET_TIMEOUT,
|
||||||
|
},
|
||||||
|
) as celery_connection:
|
||||||
|
for ping_attempt in range(3):
|
||||||
|
celery_ping = celery_app.control.inspect(
|
||||||
|
connection=celery_connection,
|
||||||
|
).ping()
|
||||||
|
if celery_ping:
|
||||||
|
break
|
||||||
|
if ping_attempt < 2:
|
||||||
|
sleep(0.25)
|
||||||
|
|
||||||
if not celery_ping:
|
if not celery_ping:
|
||||||
celery_active = "WARNING"
|
celery_active = "WARNING"
|
||||||
|
|||||||
Reference in new issue
Block a user