diff --git a/src/opengeodeweb_back/app_config.py b/src/opengeodeweb_back/app_config.py index 6bbb0b1d..a4e87fc2 100644 --- a/src/opengeodeweb_back/app_config.py +++ b/src/opengeodeweb_back/app_config.py @@ -12,7 +12,6 @@ class Config(object): DEFAULT_PORT = "5000" CORS_HEADERS = "Content-Type" UPLOAD_FOLDER = "./uploads" - DESKTOP_APP = False REQUEST_COUNTER = 0 LAST_REQUEST_TIME = time.time() LAST_PING_TIME = time.time() diff --git a/src/opengeodeweb_back/utils_functions.py b/src/opengeodeweb_back/utils_functions.py index e19e744f..41cedcb8 100644 --- a/src/opengeodeweb_back/utils_functions.py +++ b/src/opengeodeweb_back/utils_functions.py @@ -43,7 +43,6 @@ def teardown_request(current_app): def kill_task(current_app): - DESKTOP_APP = bool(current_app.config.get("DESKTOP_APP")) REQUEST_COUNTER = int(current_app.config.get("REQUEST_COUNTER")) LAST_PING_TIME = float(current_app.config.get("LAST_PING_TIME")) LAST_REQUEST_TIME = float(current_app.config.get("LAST_REQUEST_TIME")) @@ -52,15 +51,19 @@ def kill_task(current_app): minutes_since_last_request = (current_time - LAST_REQUEST_TIME) / 60 minutes_since_last_ping = (current_time - LAST_PING_TIME) / 60 - if ( - ( - (minutes_since_last_request > MINUTES_BEFORE_TIMEOUT) - and (DESKTOP_APP == False) - ) - or (minutes_since_last_ping > MINUTES_BEFORE_TIMEOUT) - ) and (REQUEST_COUNTER == 0): - print("Server timed out due to inactivity, shutting down...", flush=True) - os._exit(0) + if REQUEST_COUNTER > 0: + return + if MINUTES_BEFORE_TIMEOUT == 0: + return + if minutes_since_last_ping > MINUTES_BEFORE_TIMEOUT: + kill_server() + if minutes_since_last_request > MINUTES_BEFORE_TIMEOUT: + kill_server() + + +def kill_server(): + print("Server timed out due to inactivity, shutting down...", flush=True) + os._exit(0) def versions(list_packages: list):