Skip to content

Commit 493abce

Browse files
author
Ferenc Hammerl
committed
Extract the logic from run.cmd
1 parent 66dde76 commit 493abce

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

src/Misc/layoutbin/run-helper.cmd

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@echo off
2+
3+
"%~dp0Runner.Listener.exe" run %*
4+
5+
rem using `if %ERRORLEVEL% EQU N` insterad of `if ERRORLEVEL N`
6+
rem `if ERRORLEVEL N` means: error level is N or MORE
7+
8+
if %ERRORLEVEL% EQU 0 (
9+
echo "Runner listener exit with 0 return code, stop the service, no retry needed."
10+
)
11+
12+
if %ERRORLEVEL% EQU 1 (
13+
echo "Runner listener exit with terminated error, stop the service, no retry needed."
14+
)
15+
16+
if %ERRORLEVEL% EQU 2 (
17+
echo "Runner listener exit with retryable error, re-launch runner in 5 seconds."
18+
timeout /t 5 /nobreak > NUL
19+
goto :launch_listener
20+
)
21+
22+
rem Return code 4 means the runner received an update message.
23+
if %ERRORLEVEL% EQU 3 (
24+
echo "Runner listener exit because of updating, re-launch runner in 5 seconds"
25+
timeout /t 5 /nobreak > NUL
26+
)
27+
28+
rem Return code 4 means the ephemeral runner received an update message.
29+
if %ERRORLEVEL% EQU 4 (
30+
echo "Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
31+
timeout /t 5 /nobreak > NUL
32+
)
33+
34+
exit /b %ERRORLEVEL%

src/Misc/layoutroot/run.cmd

+8-29
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,17 @@ rem ****************************************************************************
1818
rem Run.
1919
rem ********************************************************************************
2020

21-
:launch_listener
22-
"%~dp0bin\Runner.Listener.exe" run %*
21+
:launch_helper
22+
call "%~dp0bin\run-helper.cmd" %*
2323

2424
rem using `if %ERRORLEVEL% EQU N` insterad of `if ERRORLEVEL N`
2525
rem `if ERRORLEVEL N` means: error level is N or MORE
2626

27-
if %ERRORLEVEL% EQU 0 (
28-
echo "Runner listener exit with 0 return code, stop the service, no retry needed."
27+
if %ERRORLEVEL% GEQ 2 (
28+
echo "Restart runner after it exited with return code '%ERRORLEVEL%'"
29+
goto :launch_helper
30+
) else (
31+
echo "Exit runner after it exited with return code '%ERRORLEVEL%'"
2932
exit %ERRORLEVEL%
3033
)
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
55-
)
34+
exit %ERRORLEVEL%

0 commit comments

Comments
 (0)