From 8fefcb76c48eed1ed562aabb09e9137e4c92e3cc Mon Sep 17 00:00:00 2001 From: tianmo Date: Fri, 16 Oct 2026 16:04:26 +0800 Subject: [PATCH] =?UTF-8?q?run.sh=20=E6=94=B9=E7=94=A8=20python=20subproce?= =?UTF-8?q?ss.Popen(start=5Fnew=5Fsession=3DTrue)=20=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=EF=BC=9Anohup=20=E6=96=B9=E5=BC=8F=E4=BC=9A=E8=AE=A9=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E6=8C=82=E5=9C=A8=E5=90=AF=E5=8A=A8=E5=AE=83?= =?UTF-8?q?=E7=9A=84=E4=BC=9A=E8=AF=9D=E4=B8=8B=EF=BC=8C=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E5=B0=B1=E8=A2=AB=E6=94=B6=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- viewpanel/run.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/viewpanel/run.sh b/viewpanel/run.sh index 99ed681..bfc7032 100755 --- a/viewpanel/run.sh +++ b/viewpanel/run.sh @@ -26,16 +26,25 @@ if [[ ! -f "$HERE/build/classes/com/spineview/Launcher.class" ]] \ fi echo "== 启动(工程 $PROJ)" -nohup "$JX" \ - "-javaagent:$ROOT/tools/agent/view-agent.jar" \ - -DSpineJava=1 \ - "-Dspine.payload=$PAY" \ - "-Dspine.resources=$HERE/resources" \ - "-Dspine.compat=$HERE/compat-classes" \ - "-Dspine.classes=$HERE/build/classes" \ - "-Duser.home=$ROOT/spine-lab/home" \ - -cp "$HERE/build/classes:$ASM" com.spineview.Launcher "$PROJ" \ - >"$LOG" 2>&1 & +# 注意:不能用 `nohup … &` —— 那样进程挂在本 shell 的会话里,跑这条命令的终端一结束 +# 编辑器就被一起收掉。必须 start_new_session=True 让它彻底脱离会话。 +python3 - "$JX" "$ROOT" "$HERE" "$PAY" "$PROJ" "$LOG" <<'PYEOF' +import subprocess, sys +jx, root, here, pay, proj, log = sys.argv[1:7] +cmd = [jx, + "-javaagent:" + root + "/tools/agent/view-agent.jar", + "-DSpineJava=1", + "-Dspine.payload=" + pay, + "-Dspine.resources=" + here + "/resources", + "-Dspine.compat=" + here + "/compat-classes", + "-Dspine.classes=" + here + "/build/classes", + "-Duser.home=" + root + "/spine-lab/home", + "-cp", here + "/build/classes:" + root + "/tools/asm/asm.jar:" + root + "/tools/asm/asm-tree.jar", + "com.spineview.Launcher", proj] +with open(log, "ab") as out: + subprocess.Popen(cmd, stdout=out, stderr=out, start_new_session=True) +print("launched") +PYEOF sleep 2 echo "== 已启动:pid $(pgrep -f com.spineview.Launcher | tr '\n' ' ')"