From 6139a275c52fb366d9e2ff792258a06c2696dcd3 Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Fri, 16 Oct 2020 11:02:47 -0700 Subject: [PATCH] added proxy read timeout --- backend/api/actions/apps.py | 3 ++- backend/api/utils.py | 5 ++++- nginx.conf | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/api/actions/apps.py b/backend/api/actions/apps.py index 259d6e53..2cedda06 100644 --- a/backend/api/actions/apps.py +++ b/backend/api/actions/apps.py @@ -3,6 +3,7 @@ from fastapi import HTTPException from ..db import models, schemas from ..utils import * +from ..utils import check_updates as _update_check from datetime import datetime import time @@ -30,7 +31,7 @@ def check_app_updates(): apps = dclient.containers.list(all=True) for app in apps: if app.attrs["Config"]["Image"]: - if check_updates(app.attrs["Config"]["Image"]): + if _update_check(app.attrs["Config"]["Image"]): apps_list.append(app.name) return apps_list diff --git a/backend/api/utils.py b/backend/api/utils.py index fd2912b0..d45a6231 100644 --- a/backend/api/utils.py +++ b/backend/api/utils.py @@ -278,7 +278,10 @@ async def websocket_auth(websocket: WebSocket): async def calculate_cpu_percent(d): - cpu_count = len(d["cpu_stats"]["cpu_usage"]["percpu_usage"]) + try: + cpu_count = len(d["cpu_stats"]["cpu_usage"]["percpu_usage"]) + except KeyError as exc: + pass cpu_percent = 0.0 cpu_delta = float(d["cpu_stats"]["cpu_usage"]["total_usage"]) - float( d["precpu_stats"]["cpu_usage"]["total_usage"] diff --git a/nginx.conf b/nginx.conf index ac193dd2..7469d24d 100644 --- a/nginx.conf +++ b/nginx.conf @@ -47,7 +47,9 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; - + # Set this so that the app updates function doesn't timeout + + proxy_read_timeout 300s; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade";