-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.bat
More file actions
61 lines (53 loc) · 2.16 KB
/
Copy pathstart.bat
File metadata and controls
61 lines (53 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
title ZCode Toolbar Wallpaper
set "WP_ROOT=%~dp0"
set "WP_ROOT=%WP_ROOT:~0,-1%"
set "LOG=%WP_ROOT%\.start.log"
echo === start.bat run at %date% %time% === > "%LOG%"
REM ---- Step 0: kill old server (by port 18923) ----
echo [start] Step 0/4: stopping old server ... >> "%LOG%"
for /f "tokens=5" %%P in ('netstat -ano 2^>nul ^| findstr ":18923" ^| findstr "LISTENING"') do (
taskkill /PID %%P /F >> "%LOG%" 2>&1
)
ping -n 2 127.0.0.1 >nul 2>nul
echo [start] done. >> "%LOG%"
REM ---- Step 1: Node.js check ----
echo [start] Step 1/4: checking Node.js ... >> "%LOG%"
where node >> "%LOG%" 2>&1
if errorlevel 1 (
echo [start] Node.js NOT FOUND >> "%LOG%"
goto :eof
)
echo [start] Node.js OK >> "%LOG%"
REM ---- Step 2: launch ZCode with debug port ----
echo [start] Step 2/4: checking debug port 9222 ... >> "%LOG%"
powershell -NoProfile -Command "try { $r = Invoke-WebRequest -Uri 'http://127.0.0.1:9222/json/version' -UseBasicParsing -TimeoutSec 2; if ($r.StatusCode -eq 200) { exit 0 } else { exit 1 } } catch { exit 1 }" >nul 2>nul
set portrc=!errorlevel!
echo [start] port check rc=!portrc! >> "%LOG%"
if "!portrc!"=="0" (
echo [start] Debug port already up - skipping launch. >> "%LOG%"
goto step3
)
echo [start] Launching ZCode ... >> "%LOG%"
call "%WP_ROOT%\bin\launch-zcode.bat" >> "%LOG%" 2>&1
set rc=!errorlevel!
echo [start] launch rc=!rc! >> "%LOG%"
if not "!rc!"=="0" (
echo [start] FAILED rc=!rc! >> "%LOG%"
goto :eof
)
:step3
REM ---- Step 3: start server (truly independent background process) ----
echo [start] Step 3/4: starting server ... >> "%LOG%"
powershell -NoProfile -Command "Start-Process -FilePath node -ArgumentList @('\"%WP_ROOT%\lib\server.cjs\"') -WorkingDirectory '%WP_ROOT%' -WindowStyle Hidden" >> "%LOG%" 2>&1
ping -n 3 127.0.0.1 >nul 2>nul
echo [start] Server started >> "%LOG%"
REM ---- Step 4: resize + restore + skin ----
echo [start] Step 4/4: resize + restore + skin ... >> "%LOG%"
node "%WP_ROOT%\lib\resize.cjs" >> "%LOG%" 2>&1
node "%WP_ROOT%\lib\inject.cjs" >> "%LOG%" 2>&1
node "%WP_ROOT%\lib\skin-inject.cjs" >> "%LOG%" 2>&1
echo [start] Done >> "%LOG%"
endlocal