From 3b6fb51f7ff46b657395b67256afcd5feec5ee75 Mon Sep 17 00:00:00 2001 From: Matisse Hack Date: Thu, 22 Jul 2021 02:25:47 -0700 Subject: [PATCH] Self update fix when running under impersonation (#1124) * Always use run.cmd to restart runner on update * Pass args to updated run.cmd --- src/Misc/layoutroot/run.cmd | 6 +++--- src/Runner.Listener/Runner.cs | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Misc/layoutroot/run.cmd b/src/Misc/layoutroot/run.cmd index df5fd3909..64c50e2b4 100644 --- a/src/Misc/layoutroot/run.cmd +++ b/src/Misc/layoutroot/run.cmd @@ -24,10 +24,10 @@ if /i "%~1" equ "localRun" ( rem ******************************************************************************** "%~dp0bin\Runner.Listener.exe" run %* - rem Return code 4 means the run once runner received an update message. + rem Return codes 3 and 4 mean the runner received an update message. rem Sleep 5 seconds to wait for the update process finish and run the runner again. - if ERRORLEVEL 4 ( + if ERRORLEVEL 3 ( timeout /t 5 /nobreak > NUL - "%~dp0bin\Runner.Listener.exe" run %* + "%~dp0run.cmd" %* ) ) diff --git a/src/Runner.Listener/Runner.cs b/src/Runner.Listener/Runner.cs index 68b0b4ecd..50dbbb82f 100644 --- a/src/Runner.Listener/Runner.cs +++ b/src/Runner.Listener/Runner.cs @@ -396,7 +396,14 @@ namespace GitHub.Runner.Listener autoUpdateInProgress = true; var runnerUpdateMessage = JsonUtility.FromString(message.Body); var selfUpdater = HostContext.GetService(); - selfUpdateTask = selfUpdater.SelfUpdate(runnerUpdateMessage, jobDispatcher, !runOnce && HostContext.StartupType != StartupType.Service, HostContext.RunnerShutdownToken); + +#if OS_WINDOWS + var restartInteractiveRunner = false; +#else + var restartInteractiveRunner = !runOnce; +#endif + + selfUpdateTask = selfUpdater.SelfUpdate(runnerUpdateMessage, jobDispatcher, restartInteractiveRunner, HostContext.RunnerShutdownToken); Trace.Info("Refresh message received, kick-off selfupdate background process."); } else