Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize and fix exit code handling #3406

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Misc/layoutbin/RunnerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ var runService = function () {

if (!stopping) {
setTimeout(runService, 5000);
} else {
process.exitCode = code;
}
});
} catch (ex) {
Expand Down
12 changes: 6 additions & 6 deletions src/Misc/layoutroot/run-helper.cmd.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ if %ERRORLEVEL% EQU 0 (

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

if %ERRORLEVEL% EQU 2 (
echo "Runner listener exit with retryable error, re-launch runner in 5 seconds."
ping 127.0.0.1 -n 6 -w 1000 >NUL
exit /b 1
exit /b 2
)

if %ERRORLEVEL% EQU 3 (
Expand All @@ -32,7 +32,7 @@ if %ERRORLEVEL% EQU 3 (
)
ping 127.0.0.1 -n 2 -w 1000 >NUL
)
exit /b 1
exit /b 2
)

if %ERRORLEVEL% EQU 4 (
Expand All @@ -46,13 +46,13 @@ if %ERRORLEVEL% EQU 4 (
)
ping 127.0.0.1 -n 2 -w 1000 >NUL
)
exit /b 1
exit /b 2
)

if %ERRORLEVEL% EQU 5 (
echo "Runner listener exit with Session Conflict error, stop the service, no retry needed."
exit /b 0
exit /b 5
)

echo "Exiting after unknown error code: %ERRORLEVEL%"
exit /b 0
exit /b %ERRORLEVEL%
6 changes: 3 additions & 3 deletions src/Misc/layoutroot/run-helper.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if [[ $returnCode == 0 ]]; then
exit 0
elif [[ $returnCode == 1 ]]; then
echo "Runner listener exit with terminated error, stop the service, no retry needed."
exit 0
exit 1
elif [[ $returnCode == 2 ]]; then
echo "Runner listener exit with retryable error, re-launch runner in 5 seconds."
"$DIR"/safe_sleep.sh 5
Expand Down Expand Up @@ -72,8 +72,8 @@ elif [[ $returnCode == 4 ]]; then
exit 2
elif [[ $returnCode == 5 ]]; then
echo "Runner listener exit with Session Conflict error, stop the service, no retry needed."
exit 0
exit 5
else
echo "Exiting with unknown error code: ${returnCode}"
exit 0
exit $returnCode
fi
4 changes: 2 additions & 2 deletions src/Misc/layoutroot/run.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ rem ****************************************************************************
copy "%~dp0run-helper.cmd.template" "%~dp0run-helper.cmd" /Y
call "%~dp0run-helper.cmd" %*

if %ERRORLEVEL% EQU 1 (
if %ERRORLEVEL% EQU 2 (
echo "Restarting runner..."
goto :launch_helper
) else (
echo "Exiting runner..."
exit /b 0
exit /b %ERRORLEVEL%
)
2 changes: 1 addition & 1 deletion src/Misc/layoutroot/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ run() {
echo "Restarting runner..."
else
echo "Exiting runner..."
exit 0
exit $returnCode
fi
done
}
Expand Down