mirror of
https://github.com/actions/runner.git
synced 2025-12-10 20:36:49 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4e17c4fee | ||
|
|
b1ebc2aae4 | ||
|
|
444f054278 |
@@ -1 +1 @@
|
|||||||
<Update to ./src/runnerversion when creating release>
|
2.287.1
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
@echo off
|
|
||||||
|
|
||||||
"%~dp0\bin\Runner.Listener.exe" run %*
|
|
||||||
|
|
||||||
rem using `if %ERRORLEVEL% EQU N` insterad of `if ERRORLEVEL N`
|
|
||||||
rem `if ERRORLEVEL N` means: error level is N or MORE
|
|
||||||
|
|
||||||
if %ERRORLEVEL% EQU 0 (
|
|
||||||
echo "Runner listener exit with 0 return code, stop the service, no retry needed."
|
|
||||||
exit /b 0
|
|
||||||
)
|
|
||||||
|
|
||||||
if %ERRORLEVEL% EQU 1 (
|
|
||||||
echo "Runner listener exit with terminated error, stop the service, no retry needed."
|
|
||||||
exit /b 0
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
if %ERRORLEVEL% EQU 3 (
|
|
||||||
rem Sleep 5 seconds to wait for the runner update process finish
|
|
||||||
echo "Runner listener exit because of updating, re-launch runner in 5 seconds"
|
|
||||||
ping 127.0.0.1 -n 6 -w 1000 >NUL
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
if %ERRORLEVEL% EQU 4 (
|
|
||||||
rem Sleep 5 seconds to wait for the ephemeral runner update process finish
|
|
||||||
echo "Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
|
|
||||||
ping 127.0.0.1 -n 6 -w 1000 >NUL
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
echo "Exiting after unknown error code: %ERRORLEVEL%"
|
|
||||||
exit /b 0
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Validate not sudo
|
|
||||||
user_id=`id -u`
|
|
||||||
if [ $user_id -eq 0 -a -z "$RUNNER_ALLOW_RUNASROOT" ]; then
|
|
||||||
echo "Must not run interactively with sudo"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run
|
|
||||||
shopt -s nocasematch
|
|
||||||
|
|
||||||
safe_sleep() {
|
|
||||||
if [ ! -x "$(command -v sleep)" ]; then
|
|
||||||
if [ ! -x "$(command -v ping)" ]; then
|
|
||||||
COUNT="0"
|
|
||||||
while [[ $COUNT != 5000 ]]; do
|
|
||||||
echo "SLEEP" > /dev/null
|
|
||||||
COUNT=$[$COUNT+1]
|
|
||||||
done
|
|
||||||
else
|
|
||||||
ping -c 5 127.0.0.1 > /dev/null
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
sleep 5
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
bin/Runner.Listener run $*
|
|
||||||
returnCode=$?
|
|
||||||
if [[ $returnCode == 0 ]]; then
|
|
||||||
echo "Runner listener exit with 0 return code, stop the service, no retry needed."
|
|
||||||
exit 0
|
|
||||||
elif [[ $returnCode == 1 ]]; then
|
|
||||||
echo "Runner listener exit with terminated error, stop the service, no retry needed."
|
|
||||||
exit 0
|
|
||||||
elif [[ $returnCode == 2 ]]; then
|
|
||||||
echo "Runner listener exit with retryable error, re-launch runner in 5 seconds."
|
|
||||||
safe_sleep
|
|
||||||
exit 1
|
|
||||||
elif [[ $returnCode == 3 ]]; then
|
|
||||||
# Sleep 5 seconds to wait for the runner update process finish
|
|
||||||
echo "Runner listener exit because of updating, re-launch runner in 5 seconds"
|
|
||||||
safe_sleep
|
|
||||||
exit 1
|
|
||||||
elif [[ $returnCode == 4 ]]; then
|
|
||||||
# Sleep 5 seconds to wait for the ephemeral runner update process finish
|
|
||||||
echo "Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
|
|
||||||
safe_sleep
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "Exiting with unknown error code: ${returnCode}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
@@ -13,19 +13,21 @@ if defined VERBOSE_ARG (
|
|||||||
rem Unblock files in the root of the layout folder. E.g. .cmd files.
|
rem Unblock files in the root of the layout folder. E.g. .cmd files.
|
||||||
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"
|
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"
|
||||||
|
|
||||||
|
if /i "%~1" equ "localRun" (
|
||||||
|
rem ********************************************************************************
|
||||||
|
rem Local run.
|
||||||
|
rem ********************************************************************************
|
||||||
|
"%~dp0bin\Runner.Listener.exe" %*
|
||||||
|
) else (
|
||||||
|
rem ********************************************************************************
|
||||||
|
rem Run.
|
||||||
|
rem ********************************************************************************
|
||||||
|
"%~dp0bin\Runner.Listener.exe" run %*
|
||||||
|
|
||||||
rem ********************************************************************************
|
rem Return code 4 means the run once runner received an update message.
|
||||||
rem Run.
|
rem Sleep 5 seconds to wait for the update process finish and run the runner again.
|
||||||
rem ********************************************************************************
|
if ERRORLEVEL 4 (
|
||||||
|
timeout /t 5 /nobreak > NUL
|
||||||
:launch_helper
|
"%~dp0bin\Runner.Listener.exe" run %*
|
||||||
copy run-helper.cmd.template run-helper.cmd /Y
|
)
|
||||||
call "%~dp0run-helper.cmd" %*
|
|
||||||
|
|
||||||
if %ERRORLEVEL% EQU 1 (
|
|
||||||
echo "Restarting runner..."
|
|
||||||
goto :launch_helper
|
|
||||||
) else (
|
|
||||||
echo "Exiting runner..."
|
|
||||||
exit 0
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,24 +1,64 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Validate not sudo
|
||||||
|
user_id=`id -u`
|
||||||
|
if [ $user_id -eq 0 -a -z "$RUNNER_ALLOW_RUNASROOT" ]; then
|
||||||
|
echo "Must not run interactively with sudo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Change directory to the script root directory
|
# Change directory to the script root directory
|
||||||
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
|
# https://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
|
||||||
SOURCE="${BASH_SOURCE[0]}"
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
SOURCE="$(readlink "$SOURCE")"
|
SOURCE="$(readlink "$SOURCE")"
|
||||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||||
done
|
done
|
||||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
cp -f run-helper.sh.template run-helper.sh
|
|
||||||
# run the helper process which keep the listener alive
|
# Do not "cd $DIR". For localRun, the current directory is expected to be the repo location on disk.
|
||||||
while :;
|
|
||||||
do
|
# Run
|
||||||
"$DIR"/run-helper.sh $*
|
shopt -s nocasematch
|
||||||
|
if [[ "$1" == "localRun" ]]; then
|
||||||
|
"$DIR"/bin/Runner.Listener $*
|
||||||
|
else
|
||||||
|
"$DIR"/bin/Runner.Listener run $*
|
||||||
|
|
||||||
|
# Return code 3 means the run once runner received an update message.
|
||||||
|
# Sleep 5 seconds to wait for the update process finish
|
||||||
returnCode=$?
|
returnCode=$?
|
||||||
if [[ $returnCode == 1 ]]; then
|
if [[ $returnCode == 3 ]]; then
|
||||||
echo "Restarting runner..."
|
if [ ! -x "$(command -v sleep)" ]; then
|
||||||
|
if [ ! -x "$(command -v ping)" ]; then
|
||||||
|
COUNT="0"
|
||||||
|
while [[ $COUNT != 5000 ]]; do
|
||||||
|
echo "SLEEP" > /dev/null
|
||||||
|
COUNT=$[$COUNT+1]
|
||||||
|
done
|
||||||
|
else
|
||||||
|
ping -c 5 127.0.0.1 > /dev/null
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
elif [[ $returnCode == 4 ]]; then
|
||||||
|
if [ ! -x "$(command -v sleep)" ]; then
|
||||||
|
if [ ! -x "$(command -v ping)" ]; then
|
||||||
|
COUNT="0"
|
||||||
|
while [[ $COUNT != 5000 ]]; do
|
||||||
|
echo "SLEEP" > /dev/null
|
||||||
|
COUNT=$[$COUNT+1]
|
||||||
|
done
|
||||||
|
else
|
||||||
|
ping -c 5 127.0.0.1 > /dev/null
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
"$DIR"/bin/Runner.Listener run $*
|
||||||
else
|
else
|
||||||
echo "Exiting runner..."
|
exit $returnCode
|
||||||
exit 0
|
|
||||||
fi
|
fi
|
||||||
done
|
fi
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
Trace.Info(nameof(LoadSettings));
|
Trace.Info(nameof(LoadSettings));
|
||||||
if (!IsConfigured())
|
if (!IsConfigured())
|
||||||
{
|
{
|
||||||
throw new NonRetryableException("Not configured. Run config.(sh/cmd) to configure the runner.");
|
throw new InvalidOperationException("Not configured. Run config.(sh/cmd) to configure the runner.");
|
||||||
}
|
}
|
||||||
|
|
||||||
RunnerSettings settings = _store.GetSettings();
|
RunnerSettings settings = _store.GetSettings();
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ namespace GitHub.Runner.Listener
|
|||||||
autoUpdateInProgress = true;
|
autoUpdateInProgress = true;
|
||||||
var runnerUpdateMessage = JsonUtility.FromString<AgentRefreshMessage>(message.Body);
|
var runnerUpdateMessage = JsonUtility.FromString<AgentRefreshMessage>(message.Body);
|
||||||
var selfUpdater = HostContext.GetService<ISelfUpdater>();
|
var selfUpdater = HostContext.GetService<ISelfUpdater>();
|
||||||
selfUpdateTask = selfUpdater.SelfUpdate(runnerUpdateMessage, jobDispatcher, false, HostContext.RunnerShutdownToken);
|
selfUpdateTask = selfUpdater.SelfUpdate(runnerUpdateMessage, jobDispatcher, !runOnce && HostContext.StartupType != StartupType.Service, HostContext.RunnerShutdownToken);
|
||||||
Trace.Info("Refresh message received, kick-off selfupdate background process.");
|
Trace.Info("Refresh message received, kick-off selfupdate background process.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
2.287.0
|
2.287.1
|
||||||
|
|||||||
Reference in New Issue
Block a user