diff --git a/requirements.txt b/requirements.txt index 76111aa7..ff9ae20e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -60,4 +60,3 @@ werkzeug==3.1.8 # flask # flask-cors -opengeodeweb-microservice==1.*,>=1.1.3 diff --git a/src/opengeodeweb_back/app.py b/src/opengeodeweb_back/app.py index 2a9990cf..7422ad4b 100644 --- a/src/opengeodeweb_back/app.py +++ b/src/opengeodeweb_back/app.py @@ -2,6 +2,7 @@ import argparse import os +from threading import Timer from typing import Any import flask import flask_cors # type: ignore @@ -76,7 +77,7 @@ def root() -> Response: @cross_origin() def kill() -> None: print("Manual server kill, shutting down...", flush=True) - os._exit(0) + Timer(1.5, os._exit, [0]).start() return app diff --git a/src/opengeodeweb_back/routes/blueprint_routes.py b/src/opengeodeweb_back/routes/blueprint_routes.py index f5aff23e..2e65a884 100644 --- a/src/opengeodeweb_back/routes/blueprint_routes.py +++ b/src/opengeodeweb_back/routes/blueprint_routes.py @@ -3,6 +3,7 @@ import time import shutil import math +from threading import Timer from typing import Any, Union, get_args # Third party imports @@ -510,7 +511,8 @@ def ping() -> flask.Response: def kill() -> flask.Response: print("Manual server kill, shutting down...", flush=True) utils_functions.teardown_request(flask.current_app) - os._exit(0) + Timer(1.5, os._exit, [0]).start() + return flask.make_response({"message": "Flask server is dead"}, 200) diff --git a/src/opengeodeweb_back/utils_functions.py b/src/opengeodeweb_back/utils_functions.py index 8a103814..34e5cf3b 100644 --- a/src/opengeodeweb_back/utils_functions.py +++ b/src/opengeodeweb_back/utils_functions.py @@ -106,11 +106,6 @@ def kill_task(current_app: flask.Flask) -> bool: return False -def kill_server() -> None: - print("Server timed out due to inactivity, shutting down...", flush=True) - os._exit(0) - - def versions(list_packages: list[str]) -> list[dict[str, str]]: list_with_versions = [] for package in list_packages: