@@ -13,21 +13,43 @@ if defined VERBOSE_ARG (
13
13
rem Unblock files in the root of the layout folder. E.g. .cmd files.
14
14
powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command " $VerbosePreference = %VERBOSE_ARG% ; Get-ChildItem -LiteralPath '%~dp0 ' | ForEach-Object { Write-Verbose ('Unblock: {0}' -f $_.FullName) ; $_ } | Unblock-File | Out-Null"
15
15
16
- if /i " %~1 " equ " localRun" (
17
- rem ********************************************************************************
18
- rem Local run.
19
- rem ********************************************************************************
20
- " %~dp0 bin\Runner.Listener.exe" %*
21
- ) else (
22
- rem ********************************************************************************
23
- rem Run.
24
- rem ********************************************************************************
25
- " %~dp0 bin\Runner.Listener.exe" run %*
26
-
27
- rem Return code 4 means the run once runner received an update message.
28
- rem Sleep 5 seconds to wait for the update process finish and run the runner again.
29
- if ERRORLEVEL 4 (
30
- timeout /t 5 /nobreak > NUL
31
- " %~dp0 bin\Runner.Listener.exe" run %*
32
- )
16
+
17
+ rem ********************************************************************************
18
+ rem Run.
19
+ rem ********************************************************************************
20
+
21
+ :relaunch_listener
22
+ " %~dp0 bin\Runner.Listener.exe" run %*
23
+
24
+ rem using `if %ERRORLEVEL% EQU N` insterad of `if ERRORLEVEL N`
25
+ rem `if ERRORLEVEL N` means: error level is N or MORE
26
+
27
+ if %ERRORLEVEL% EQU 0 (
28
+ echo " Runner listener exit with 0 return code, stop the service, no retry needed."
29
+ exit %ERRORLEVEL%
30
+ )
31
+
32
+ if %ERRORLEVEL% EQU 1 (
33
+ echo " Runner listener exit with terminated error, stop the service, no retry needed."
34
+ exit %ERRORLEVEL%
35
+ )
36
+
37
+ if %ERRORLEVEL% EQU 2 (
38
+ echo " Runner listener exit with retryable error, re-launch runner in 5 seconds."
39
+ timeout /t 5 /nobreak > NUL
40
+ goto :launch_listener
41
+ )
42
+
43
+ rem Return code 4 means the runner received an update message.
44
+ if %ERRORLEVEL% EQU 3 (
45
+ echo " Runner listener exit because of updating, re-launch runner in 5 seconds"
46
+ timeout /t 5 /nobreak > NUL
47
+ goto :launch_listener
48
+ )
49
+
50
+ rem Return code 4 means the ephemeral runner received an update message.
51
+ if %ERRORLEVEL% EQU 4 (
52
+ echo " Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
53
+ timeout /t 5 /nobreak > NUL
54
+ goto :launch_listener
33
55
)
0 commit comments