Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/opengeodeweb_back/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 13 additions & 10 deletions src/opengeodeweb_back/utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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):
Expand Down