From b1c20ddcffa8b7c48c4fafa8b92c066a7d890d94 Mon Sep 17 00:00:00 2001 From: ekremsekerci Date: Tue, 4 Feb 2025 14:22:45 +0100 Subject: [PATCH] Update on error scripts --- buildpack/core/runtime.py | 22 +++++++++++++++++++++- etc/m2ee/m2ee.yaml | 1 - etc/scripts/on_error.sh | 3 +-- etc/scripts/on_out_of_memory_error.sh | 3 +-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/buildpack/core/runtime.py b/buildpack/core/runtime.py index a7fbf752..feb6c4c4 100644 --- a/buildpack/core/runtime.py +++ b/buildpack/core/runtime.py @@ -630,14 +630,34 @@ def _pre_process_m2ee_yaml(): f"s|BUILD_PATH|{os.getcwd()}|g; " f"s|RUNTIME_PORT|{util.get_runtime_port()}|; " f"s|ADMIN_PORT|{util.get_admin_port()}|; " - f"s|PYTHONPID|{os.getpid()}|", # TODO Replace in new scripts ".local/m2ee.yaml", ] ) +def _pre_process_on_error_scripts(): + logging.debug("Preprocessing on error scripts...") + subprocess.check_call( + [ + "sed", + "-i", + f"s|PYTHONPID|{os.getpid()}|", + ".local/scripts/on_error.sh", + ] + ) + subprocess.check_call( + [ + "sed", + "-i", + f"s|PYTHONPID|{os.getpid()}|", + ".local/scripts/on_out_of_memory_error.sh", + ] + ) + + def setup(vcap_data): _pre_process_m2ee_yaml() + _pre_process_on_error_scripts() _activate_license() client = m2ee_class( diff --git a/etc/m2ee/m2ee.yaml b/etc/m2ee/m2ee.yaml index d46378a2..e80f6254 100644 --- a/etc/m2ee/m2ee.yaml +++ b/etc/m2ee/m2ee.yaml @@ -26,7 +26,6 @@ m2ee: "-XX:OnError=/home/vcap/app/.local/scripts/on_error.sh", "-XX:OnOutOfMemoryError=/home/vcap/app/.local/scripts/on_out_of_memory_error.sh", ] - # TODO Replace with BUILD_PATH jetty: max_form_content_size: 10485760 diff --git a/etc/scripts/on_error.sh b/etc/scripts/on_error.sh index 8eb9f212..2d9ccd7b 100755 --- a/etc/scripts/on_error.sh +++ b/etc/scripts/on_error.sh @@ -1,2 +1 @@ -echo "### THIS IS ON ERROR SCRIPT ###" -# TODO Write actual signal command \ No newline at end of file +kill -s USR1 PYTHONPID \ No newline at end of file diff --git a/etc/scripts/on_out_of_memory_error.sh b/etc/scripts/on_out_of_memory_error.sh index e63c53ee..fcba7c3a 100755 --- a/etc/scripts/on_out_of_memory_error.sh +++ b/etc/scripts/on_out_of_memory_error.sh @@ -1,2 +1 @@ -echo "### THIS IS ON OOM SCRIPT ###" -# TODO Write actual signal command \ No newline at end of file +kill -s USR2 PYTHONPID \ No newline at end of file