From fbf1b25423d4971f8251da9419671977e4737520 Mon Sep 17 00:00:00 2001 From: thrustingballsdeepinyou Date: Sat, 4 Apr 2026 20:14:59 +0000 Subject: [PATCH] Upload files to "/" --- start-java.ts | 26 ++++++++++++++++++++++++++ tsconfig.json | 6 ++++++ 2 files changed, 32 insertions(+) create mode 100644 start-java.ts create mode 100644 tsconfig.json diff --git a/start-java.ts b/start-java.ts new file mode 100644 index 0000000..0ae0b40 --- /dev/null +++ b/start-java.ts @@ -0,0 +1,26 @@ +import fs from "node:fs"; +import child_process from "node:child_process"; + +type Properties = { + "jar-file": string, + "terminal"?: boolean, + "minimum-mem"?: string, + "maximum-mem"?: string +} + +let jvm_properties: Properties = JSON.parse(fs.readFileSync("jvm-properties.json", { encoding: "utf8" })); + +if (jvm_properties["jar-file"] === undefined) throw new Error("`jar-file` is a required option."); + +if (jvm_properties["terminal"] === undefined) jvm_properties["terminal"] = false; +if (jvm_properties["minimum-mem"] === undefined) jvm_properties["minimum-mem"] = "1G"; +if (jvm_properties["maximum-mem"] === undefined) jvm_properties["maximum-mem"] = "4G"; + +let subprocess = child_process.spawn(jvm_properties["terminal"] ? "java" : "javaw", + [`-Xms${ jvm_properties["minimum-mem"] }`, + `-Xmx${ jvm_properties["maximum-mem"] }`, + "-jar", jvm_properties["jar-file"]], + { stdio: "ignore", detached: true, windowsHide: !jvm_properties["terminal"] } +); + +subprocess.unref(); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b87c191 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": + { + "module": "es6" + } +} \ No newline at end of file