README 外链图片转存 OSS

This commit is contained in:
lxp
2026-11-03 17:27:22 +08:00
parent c5be9835bf
commit 175c49e0e7
35 changed files with 1557 additions and 99 deletions
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
"""读取 dotenv 字面量并启动 Java,不将配置交给 shell 求值。"""
import os
import pathlib
import re
import sys
def load_environment(path, inherited):
values = dict(inherited)
if path.exists():
for number, line in enumerate(path.read_text(encoding="utf-8-sig").splitlines(), 1):
if not line.strip() or line.lstrip().startswith("#"):
continue
match = re.fullmatch(r"\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=(.*)", line)
if not match:
raise ValueError(f"环境文件第 {number} 行格式不合法")
value = match[2].strip()
if value[:1] in ("'", '"'):
if len(value) < 2 or value[-1] != value[0]:
raise ValueError(f"环境文件第 {number} 行引号未闭合")
value = value[1:-1]
else:
value = re.split(r"\s+#", value, maxsplit=1)[0].rstrip()
values[match[1]] = value
return values
if __name__ == "__main__":
try:
root = pathlib.Path(__file__).resolve().parent.parent
environment = load_environment(pathlib.Path(os.environ.get("VIBEMAKE_ENV_FILE", root / ".env")), os.environ)
if len(sys.argv) < 2:
raise ValueError("缺少 Java 启动参数")
os.execvpe("java", ["java", *sys.argv[1:]], environment)
except (ValueError, OSError) as error:
# 不回显配置内容或底层异常文本。
print(f"Java 启动失败 type={type(error).__name__}", file=sys.stderr)
sys.exit(1)