From 7dc42b74674a60bb02a9bcdb8620d782c3b45393 Mon Sep 17 00:00:00 2001 From: ekremsekerci Date: Mon, 3 Feb 2025 15:44:34 +0100 Subject: [PATCH] Use scripts instead of direct commands in java opts --- buildpack/core/runtime.py | 8 +++++++- etc/m2ee/m2ee.yaml | 5 +++-- etc/scripts/on_error.sh | 2 ++ etc/scripts/on_out_of_memory_error.sh | 2 ++ 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 etc/scripts/on_error.sh create mode 100755 etc/scripts/on_out_of_memory_error.sh diff --git a/buildpack/core/runtime.py b/buildpack/core/runtime.py index a9e79c6a1..9e16de211 100644 --- a/buildpack/core/runtime.py +++ b/buildpack/core/runtime.py @@ -68,6 +68,12 @@ def stage(buildpack_dir, build_path, cache_path): os.path.join(buildpack_dir, "etc", "m2ee", "m2ee.yaml"), os.path.join(build_path, ".local", "m2ee.yaml"), ) + shutil.copytree( + os.path.join(buildpack_dir, "etc", "scripts"), + os.path.join(build_path, ".local", "scripts"), + dirs_exist_ok=True + ) + resolve_runtime_dependency(buildpack_dir, build_path, cache_path) @@ -614,7 +620,7 @@ 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()}|", + f"s|PYTHONPID|{os.getpid()}|", # TODO Replace in new scripts ".local/m2ee.yaml", ] ) diff --git a/etc/m2ee/m2ee.yaml b/etc/m2ee/m2ee.yaml index 5f00c57c4..d46378a28 100644 --- a/etc/m2ee/m2ee.yaml +++ b/etc/m2ee/m2ee.yaml @@ -23,9 +23,10 @@ m2ee: [ "-Dfile.encoding=UTF-8", "-Djava.io.tmpdir=/tmp", - "-XX:OnError=/home/vcap/app/on_error_script.sh", - "-XX:OnOutOfMemoryError=/home/vcap/app/on_oom.sh", + "-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 new file mode 100755 index 000000000..8eb9f2123 --- /dev/null +++ b/etc/scripts/on_error.sh @@ -0,0 +1,2 @@ +echo "### THIS IS ON ERROR SCRIPT ###" +# TODO Write actual signal command \ 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 new file mode 100755 index 000000000..e63c53eef --- /dev/null +++ b/etc/scripts/on_out_of_memory_error.sh @@ -0,0 +1,2 @@ +echo "### THIS IS ON OOM SCRIPT ###" +# TODO Write actual signal command \ No newline at end of file