forked from kirillkovalenko/nssm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_vs2008.bat
More file actions
116 lines (98 loc) · 3.35 KB
/
Copy pathverify_vs2008.bat
File metadata and controls
116 lines (98 loc) · 3.35 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
@echo off
setlocal enabledelayedexpansion
rem ============================================================
rem VS2008 32-bit Full Verification
rem
rem 1. Build NSSM Release Win32 (devenv.com)
rem 2. Build demo_svc.exe (via demo\build.bat)
rem 3. Copy both to demo\ directory
rem 4. Install -> Start -> Test HTTP -> Stop -> Remove
rem 5. Verify service fully removed
rem
rem Must run as Administrator.
rem ============================================================
cd /d "%~dp0"
if not defined VS90COMNTOOLS (
echo [ERROR] VS90COMNTOOLS not set. Is VS2008 installed?
exit /b 1
)
set "DEVENV=%VS90COMNTOOLS%\..\IDE\devenv.com"
if not exist "%DEVENV%" echo [ERROR] devenv.com not found: "%DEVENV%" & exit /b 1
echo ============================================
echo VS2008 32-bit Full Verification
echo ============================================
echo.
rem ---- 1. Build NSSM Release Win32 ----
echo [1/6] Building NSSM Release Win32 (devenv.com) ...
"%DEVENV%" nssm90.sln /Build "Release|Win32"
if errorlevel 1 echo [FAILED] NSSM build & exit /b 1
echo OK
echo.
rem ---- 2. Build demo_svc (via demo\build.bat, which sets up the VS2008 env) ----
echo [2/6] Building demo_svc.exe ...
call demo\build.bat
if errorlevel 1 echo [FAILED] demo_svc build & exit /b 1
cd /d "%~dp0"
echo OK
echo.
rem ---- 3. Copy to demo directory ----
echo [3/6] Copying nssm.exe to demo\ ...
copy /Y out\Release\win32\nssm.exe demo\nssm.exe >nul
if errorlevel 1 echo [FAILED] Copy nssm.exe & exit /b 1
echo demo\nssm.exe - copied
echo demo\demo_svc.exe - built
echo.
set NSSM=%cd%\demo\nssm.exe
set APP=%cd%\demo\demo_svc.exe
set SVC=demo_vs2008
set PORT=18081
rem ---- 4. Install + Start + Test ----
echo [4/6] Installing service '%SVC%' ...
"%NSSM%" install %SVC% "%APP%" %PORT%
if errorlevel 1 goto cleanup
echo OK
echo.
echo [5/6] Starting service ...
"%NSSM%" start %SVC%
if errorlevel 1 echo [WARN] Start returned non-zero, checking status ...
set TRIES=0
:waitloop
set /a TRIES+=1
if !TRIES! GTR 15 goto cleanup
ping -n 2 127.0.0.1 >nul
"%NSSM%" status %SVC% 2>nul | findstr /i "RUNNING" >nul
if errorlevel 1 goto waitloop
echo Service is RUNNING
echo.
echo Testing HTTP (http://localhost:%PORT%/health) ...
powershell -Command "$r=Invoke-WebRequest -Uri 'http://localhost:%PORT%/health' -TimeoutSec 5 -UseBasicParsing;if($r.StatusCode -eq 200){exit 0}else{exit 1}" >nul 2>&1
if not errorlevel 1 echo /health returned 200 OK
if errorlevel 1 echo [WARN] Could not reach endpoint.
echo.
echo Service is running. Waiting 15 seconds for manual verification ...
echo Open http://localhost:%PORT%/health in a browser to check.
ping -n 16 127.0.0.1 >nul
echo.
echo Status:
"%NSSM%" status %SVC%
echo AppExit default:
"%NSSM%" get %SVC% AppExit Default 2>nul
echo.
rem ---- 6. Stop + Remove + Verify ----
:cleanup
echo [6/6] Stopping service ...
"%NSSM%" stop %SVC% 2>nul
ping -n 3 127.0.0.1 >nul
echo Removing service ...
"%NSSM%" remove %SVC% confirm 2>nul
ping -n 2 127.0.0.1 >nul
echo Verifying removal ...
"%NSSM%" status %SVC% 2>nul
if not errorlevel 1 echo [WARN] Service still exists!
if errorlevel 1 echo Service confirmed removed.
echo.
echo ============================================
echo VS2008 32-bit Verification Complete.
echo ============================================
endlocal
exit /b 0