Skip to content

Commit ada666b

Browse files
committed
Simplify contract between run and helper
1 parent e62aa73 commit ada666b

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

src/Misc/layoutbin/run-helper.cmd

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ rem `if ERRORLEVEL N` means: error level is N or MORE
77

88
if %ERRORLEVEL% EQU 0 (
99
echo "Runner listener exit with 0 return code, stop the service, no retry needed."
10+
exit /b 0
1011
)
1112

1213
if %ERRORLEVEL% EQU 1 (
1314
echo "Runner listener exit with terminated error, stop the service, no retry needed."
15+
exit /b 0
1416
)
1517

1618
if %ERRORLEVEL% EQU 2 (
1719
echo "Runner listener exit with retryable error, re-launch runner in 5 seconds."
1820
timeout /t 5 /nobreak > NUL
19-
goto :launch_listener
21+
exit /b 1
2022
)
2123

2224
if %ERRORLEVEL% EQU 3 (
25+
rem Sleep 5 seconds to wait for the runner update process finish
2326
echo "Runner listener exit because of updating, re-launch runner in 5 seconds"
2427
timeout /t 5 /nobreak > NUL
28+
exit /b 1
2529
)
2630

2731
if %ERRORLEVEL% EQU 4 (
32+
rem Sleep 5 seconds to wait for the ephemeral runner update process finish
2833
echo "Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
2934
timeout /t 5 /nobreak > NUL
35+
exit /b 1
3036
)
3137

32-
if %ERRORLEVEL% GEQ 5 (
33-
echo "Exiting with unknown error code: ${returnCode}"
34-
)
35-
if [%ERRORLEVEL%]==[] (
36-
echo "Exiting with empty error code: ${returnCode}"
37-
)
38-
39-
exit /b %ERRORLEVEL%
38+
echo "Exiting after unknown error code: %ERRORLEVEL%"
39+
exit /b 0

src/Misc/layoutbin/run-helper.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,25 @@ bin/Runner.Listener run $*
3030
returnCode=$?
3131
if [[ $returnCode == 0 ]]; then
3232
echo "Runner listener exit with 0 return code, stop the service, no retry needed."
33-
echo "0 ORIG"
33+
exit 0
3434
elif [[ $returnCode == 1 ]]; then
3535
echo "Runner listener exit with terminated error, stop the service, no retry needed."
36-
echo "1 ORIG"
36+
exit 0
3737
elif [[ $returnCode == 2 ]]; then
3838
echo "Runner listener exit with retryable error, re-launch runner in 5 seconds."
39-
echo "2 ORIG"
4039
safe_sleep
40+
exit 1
4141
elif [[ $returnCode == 3 ]]; then
4242
# Sleep 5 seconds to wait for the runner update process finish
4343
echo "Runner listener exit because of updating, re-launch runner in 5 seconds"
44-
echo "3 ORIG"
4544
safe_sleep
45+
exit 1
4646
elif [[ $returnCode == 4 ]]; then
4747
# Sleep 5 seconds to wait for the ephemeral runner update process finish
4848
echo "Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
49-
echo "4 ORIG"
5049
safe_sleep
50+
exit 1
5151
else
5252
echo "Exiting with unknown error code: ${returnCode}"
53+
exit 0
5354
fi
54-
55-
exit $returnCode

src/Misc/layoutroot/run.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ call "%~dp0bin\run-helper.cmd" %*
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% GEQ 2 (
27+
if %ERRORLEVEL% EQU 1 (
2828
echo "Restart runner after it exited with return code '%ERRORLEVEL%'"
2929
goto :launch_helper
3030
) else (

src/Misc/layoutroot/run.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ while :;
1515
do
1616
"$DIR"/bin/run-helper.sh $*
1717
returnCode=$?
18-
if [[ $returnCode -ge 2 ]]; then
19-
echo "Restart runner after it exited with return code '${returnCode}'"
18+
if [[ $returnCode -e 1 ]]; then
19+
echo "Restart runner after it updated..."
2020
else
21-
echo "Exit runner after it exited with return code '${returnCode}'"
22-
exit $returnCode
21+
echo "Exiting runner..."
22+
exit 0
2323
fi
2424
done

0 commit comments

Comments
 (0)