Skip to content

Commit c850c8c

Browse files
author
Ferenc Hammerl
committed
Relaunch the listener without quitting run.cmd
1 parent 7d34d02 commit c850c8c

File tree

1 file changed

+39
-17
lines changed

1 file changed

+39
-17
lines changed

src/Misc/layoutroot/run.cmd

+39-17
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,43 @@ if defined VERBOSE_ARG (
1313
rem Unblock files in the root of the layout folder. E.g. .cmd files.
1414
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"
1515

16-
if /i "%~1" equ "localRun" (
17-
rem ********************************************************************************
18-
rem Local run.
19-
rem ********************************************************************************
20-
"%~dp0bin\Runner.Listener.exe" %*
21-
) else (
22-
rem ********************************************************************************
23-
rem Run.
24-
rem ********************************************************************************
25-
"%~dp0bin\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-
"%~dp0bin\Runner.Listener.exe" run %*
32-
)
16+
17+
rem ********************************************************************************
18+
rem Run.
19+
rem ********************************************************************************
20+
21+
:relaunch_listener
22+
"%~dp0bin\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
3355
)

0 commit comments

Comments
 (0)