mirror of
https://github.com/actions/runner.git
synced 2025-12-12 14:17:46 +00:00
localrun
This commit is contained in:
committed by
TingluoHuang
parent
f2db563c89
commit
132d06dc9b
@@ -139,7 +139,6 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public bool HasCredentials()
|
public bool HasCredentials()
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
Trace.Info("HasCredentials()");
|
Trace.Info("HasCredentials()");
|
||||||
bool credsStored = (new FileInfo(_credFilePath)).Exists;
|
bool credsStored = (new FileInfo(_credFilePath)).Exists;
|
||||||
Trace.Info("stored {0}", credsStored);
|
Trace.Info("stored {0}", credsStored);
|
||||||
@@ -149,14 +148,13 @@ namespace GitHub.Runner.Common
|
|||||||
public bool IsConfigured()
|
public bool IsConfigured()
|
||||||
{
|
{
|
||||||
Trace.Info("IsConfigured()");
|
Trace.Info("IsConfigured()");
|
||||||
bool configured = HostContext.RunMode == RunMode.Local || (new FileInfo(_configFilePath)).Exists;
|
bool configured = new FileInfo(_configFilePath).Exists;
|
||||||
Trace.Info("IsConfigured: {0}", configured);
|
Trace.Info("IsConfigured: {0}", configured);
|
||||||
return configured;
|
return configured;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsServiceConfigured()
|
public bool IsServiceConfigured()
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
Trace.Info("IsServiceConfigured()");
|
Trace.Info("IsServiceConfigured()");
|
||||||
bool serviceConfigured = (new FileInfo(_serviceConfigFilePath)).Exists;
|
bool serviceConfigured = (new FileInfo(_serviceConfigFilePath)).Exists;
|
||||||
Trace.Info($"IsServiceConfigured: {serviceConfigured}");
|
Trace.Info($"IsServiceConfigured: {serviceConfigured}");
|
||||||
@@ -165,7 +163,6 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public CredentialData GetCredentials()
|
public CredentialData GetCredentials()
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
if (_creds == null)
|
if (_creds == null)
|
||||||
{
|
{
|
||||||
_creds = IOUtil.LoadObject<CredentialData>(_credFilePath);
|
_creds = IOUtil.LoadObject<CredentialData>(_credFilePath);
|
||||||
@@ -195,7 +192,6 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public void SaveCredential(CredentialData credential)
|
public void SaveCredential(CredentialData credential)
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
Trace.Info("Saving {0} credential @ {1}", credential.Scheme, _credFilePath);
|
Trace.Info("Saving {0} credential @ {1}", credential.Scheme, _credFilePath);
|
||||||
if (File.Exists(_credFilePath))
|
if (File.Exists(_credFilePath))
|
||||||
{
|
{
|
||||||
@@ -211,7 +207,6 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public void SaveSettings(RunnerSettings settings)
|
public void SaveSettings(RunnerSettings settings)
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
Trace.Info("Saving runner settings.");
|
Trace.Info("Saving runner settings.");
|
||||||
if (File.Exists(_configFilePath))
|
if (File.Exists(_configFilePath))
|
||||||
{
|
{
|
||||||
@@ -227,13 +222,11 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public void DeleteCredential()
|
public void DeleteCredential()
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
IOUtil.Delete(_credFilePath, default(CancellationToken));
|
IOUtil.Delete(_credFilePath, default(CancellationToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteSettings()
|
public void DeleteSettings()
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
IOUtil.Delete(_configFilePath, default(CancellationToken));
|
IOUtil.Delete(_configFilePath, default(CancellationToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,6 @@
|
|||||||
|
|
||||||
namespace GitHub.Runner.Common
|
namespace GitHub.Runner.Common
|
||||||
{
|
{
|
||||||
public enum RunMode
|
|
||||||
{
|
|
||||||
Normal, // Keep "Normal" first (default value).
|
|
||||||
Local,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum WellKnownDirectory
|
public enum WellKnownDirectory
|
||||||
{
|
{
|
||||||
Bin,
|
Bin,
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ namespace GitHub.Runner.Common
|
|||||||
{
|
{
|
||||||
public interface IHostContext : IDisposable
|
public interface IHostContext : IDisposable
|
||||||
{
|
{
|
||||||
RunMode RunMode { get; set; }
|
|
||||||
StartupType StartupType { get; set; }
|
StartupType StartupType { get; set; }
|
||||||
CancellationToken RunnerShutdownToken { get; }
|
CancellationToken RunnerShutdownToken { get; }
|
||||||
ShutdownReason RunnerShutdownReason { get; }
|
ShutdownReason RunnerShutdownReason { get; }
|
||||||
@@ -58,7 +57,6 @@ namespace GitHub.Runner.Common
|
|||||||
private readonly ProductInfoHeaderValue _userAgent = new ProductInfoHeaderValue($"GitHubActionsRunner-{BuildConstants.RunnerPackage.PackageName}", BuildConstants.RunnerPackage.Version);
|
private readonly ProductInfoHeaderValue _userAgent = new ProductInfoHeaderValue($"GitHubActionsRunner-{BuildConstants.RunnerPackage.PackageName}", BuildConstants.RunnerPackage.Version);
|
||||||
private CancellationTokenSource _runnerShutdownTokenSource = new CancellationTokenSource();
|
private CancellationTokenSource _runnerShutdownTokenSource = new CancellationTokenSource();
|
||||||
private object _perfLock = new object();
|
private object _perfLock = new object();
|
||||||
private RunMode _runMode = RunMode.Normal;
|
|
||||||
private Tracing _trace;
|
private Tracing _trace;
|
||||||
private Tracing _vssTrace;
|
private Tracing _vssTrace;
|
||||||
private Tracing _httpTrace;
|
private Tracing _httpTrace;
|
||||||
@@ -194,20 +192,6 @@ namespace GitHub.Runner.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RunMode RunMode
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _runMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_trace.Info($"Set run mode: {value}");
|
|
||||||
_runMode = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetDirectory(WellKnownDirectory directory)
|
public string GetDirectory(WellKnownDirectory directory)
|
||||||
{
|
{
|
||||||
string path;
|
string path;
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public async Task ConnectAsync(VssConnection jobConnection)
|
public async Task ConnectAsync(VssConnection jobConnection)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_connection = jobConnection;
|
_connection = jobConnection;
|
||||||
int attemptCount = 5;
|
int attemptCount = 5;
|
||||||
while (!_connection.HasAuthenticated && attemptCount-- > 0)
|
while (!_connection.HasAuthenticated && attemptCount-- > 0)
|
||||||
@@ -73,88 +68,48 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public Task<TaskLog> AppendLogContentAsync(Guid scopeIdentifier, string hubName, Guid planId, int logId, Stream uploadStream, CancellationToken cancellationToken)
|
public Task<TaskLog> AppendLogContentAsync(Guid scopeIdentifier, string hubName, Guid planId, int logId, Stream uploadStream, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult<TaskLog>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.AppendLogContentAsync(scopeIdentifier, hubName, planId, logId, uploadStream, cancellationToken: cancellationToken);
|
return _taskClient.AppendLogContentAsync(scopeIdentifier, hubName, planId, logId, uploadStream, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task AppendTimelineRecordFeedAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, Guid stepId, IList<string> lines, CancellationToken cancellationToken)
|
public Task AppendTimelineRecordFeedAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, Guid stepId, IList<string> lines, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.AppendTimelineRecordFeedAsync(scopeIdentifier, hubName, planId, timelineId, timelineRecordId, stepId, lines, cancellationToken: cancellationToken);
|
return _taskClient.AppendTimelineRecordFeedAsync(scopeIdentifier, hubName, planId, timelineId, timelineRecordId, stepId, lines, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, string type, string name, Stream uploadStream, CancellationToken cancellationToken)
|
public Task<TaskAttachment> CreateAttachmentAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, Guid timelineRecordId, string type, string name, Stream uploadStream, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult<TaskAttachment>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.CreateAttachmentAsync(scopeIdentifier, hubName, planId, timelineId, timelineRecordId, type, name, uploadStream, cancellationToken: cancellationToken);
|
return _taskClient.CreateAttachmentAsync(scopeIdentifier, hubName, planId, timelineId, timelineRecordId, type, name, uploadStream, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<TaskLog> CreateLogAsync(Guid scopeIdentifier, string hubName, Guid planId, TaskLog log, CancellationToken cancellationToken)
|
public Task<TaskLog> CreateLogAsync(Guid scopeIdentifier, string hubName, Guid planId, TaskLog log, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult<TaskLog>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.CreateLogAsync(scopeIdentifier, hubName, planId, log, cancellationToken: cancellationToken);
|
return _taskClient.CreateLogAsync(scopeIdentifier, hubName, planId, log, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Timeline> CreateTimelineAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, CancellationToken cancellationToken)
|
public Task<Timeline> CreateTimelineAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult<Timeline>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.CreateTimelineAsync(scopeIdentifier, hubName, planId, new Timeline(timelineId), cancellationToken: cancellationToken);
|
return _taskClient.CreateTimelineAsync(scopeIdentifier, hubName, planId, new Timeline(timelineId), cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<List<TimelineRecord>> UpdateTimelineRecordsAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, IEnumerable<TimelineRecord> records, CancellationToken cancellationToken)
|
public Task<List<TimelineRecord>> UpdateTimelineRecordsAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, IEnumerable<TimelineRecord> records, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult<List<TimelineRecord>>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.UpdateTimelineRecordsAsync(scopeIdentifier, hubName, planId, timelineId, records, cancellationToken: cancellationToken);
|
return _taskClient.UpdateTimelineRecordsAsync(scopeIdentifier, hubName, planId, timelineId, records, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task RaisePlanEventAsync<T>(Guid scopeIdentifier, string hubName, Guid planId, T eventData, CancellationToken cancellationToken) where T : JobEvent
|
public Task RaisePlanEventAsync<T>(Guid scopeIdentifier, string hubName, Guid planId, T eventData, CancellationToken cancellationToken) where T : JobEvent
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.RaisePlanEventAsync(scopeIdentifier, hubName, planId, eventData, cancellationToken: cancellationToken);
|
return _taskClient.RaisePlanEventAsync(scopeIdentifier, hubName, planId, eventData, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Timeline> GetTimelineAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, CancellationToken cancellationToken)
|
public Task<Timeline> GetTimelineAsync(Guid scopeIdentifier, string hubName, Guid planId, Guid timelineId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult<Timeline>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection();
|
CheckConnection();
|
||||||
return _taskClient.GetTimelineAsync(scopeIdentifier, hubName, planId, timelineId, includeRecords: true, cancellationToken: cancellationToken);
|
return _taskClient.GetTimelineAsync(scopeIdentifier, hubName, planId, timelineId, includeRecords: true, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ namespace GitHub.Runner.Common
|
|||||||
private Task[] _allDequeueTasks;
|
private Task[] _allDequeueTasks;
|
||||||
private readonly TaskCompletionSource<int> _jobCompletionSource = new TaskCompletionSource<int>();
|
private readonly TaskCompletionSource<int> _jobCompletionSource = new TaskCompletionSource<int>();
|
||||||
private bool _queueInProcess = false;
|
private bool _queueInProcess = false;
|
||||||
private ITerminal _term;
|
|
||||||
|
|
||||||
public event EventHandler<ThrottlingEventArgs> JobServerQueueThrottling;
|
public event EventHandler<ThrottlingEventArgs> JobServerQueueThrottling;
|
||||||
|
|
||||||
@@ -85,11 +84,6 @@ namespace GitHub.Runner.Common
|
|||||||
public void Start(Pipelines.AgentJobRequestMessage jobRequest)
|
public void Start(Pipelines.AgentJobRequestMessage jobRequest)
|
||||||
{
|
{
|
||||||
Trace.Entering();
|
Trace.Entering();
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
_term = HostContext.GetService<ITerminal>();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_queueInProcess)
|
if (_queueInProcess)
|
||||||
{
|
{
|
||||||
@@ -129,11 +123,6 @@ namespace GitHub.Runner.Common
|
|||||||
// TimelineUpdate queue error will become critical when timeline records contain output variabls.
|
// TimelineUpdate queue error will become critical when timeline records contain output variabls.
|
||||||
public async Task ShutdownAsync()
|
public async Task ShutdownAsync()
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_queueInProcess)
|
if (!_queueInProcess)
|
||||||
{
|
{
|
||||||
Trace.Info("No-op, all queue process tasks have been stopped.");
|
Trace.Info("No-op, all queue process tasks have been stopped.");
|
||||||
@@ -169,32 +158,11 @@ namespace GitHub.Runner.Common
|
|||||||
public void QueueWebConsoleLine(Guid stepRecordId, string line)
|
public void QueueWebConsoleLine(Guid stepRecordId, string line)
|
||||||
{
|
{
|
||||||
Trace.Verbose("Enqueue web console line queue: {0}", line);
|
Trace.Verbose("Enqueue web console line queue: {0}", line);
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
if ((line ?? string.Empty).StartsWith("##[section]"))
|
|
||||||
{
|
|
||||||
Console.WriteLine("******************************************************************************");
|
|
||||||
Console.WriteLine(line.Substring("##[section]".Length));
|
|
||||||
Console.WriteLine("******************************************************************************");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_webConsoleLineQueue.Enqueue(new ConsoleLineInfo(stepRecordId, line));
|
_webConsoleLineQueue.Enqueue(new ConsoleLineInfo(stepRecordId, line));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void QueueFileUpload(Guid timelineId, Guid timelineRecordId, string type, string name, string path, bool deleteSource)
|
public void QueueFileUpload(Guid timelineId, Guid timelineRecordId, string type, string name, string path, bool deleteSource)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArgUtil.NotEmpty(timelineId, nameof(timelineId));
|
ArgUtil.NotEmpty(timelineId, nameof(timelineId));
|
||||||
ArgUtil.NotEmpty(timelineRecordId, nameof(timelineRecordId));
|
ArgUtil.NotEmpty(timelineRecordId, nameof(timelineRecordId));
|
||||||
|
|
||||||
@@ -215,11 +183,6 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public void QueueTimelineRecordUpdate(Guid timelineId, TimelineRecord timelineRecord)
|
public void QueueTimelineRecordUpdate(Guid timelineId, TimelineRecord timelineRecord)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArgUtil.NotEmpty(timelineId, nameof(timelineId));
|
ArgUtil.NotEmpty(timelineId, nameof(timelineId));
|
||||||
ArgUtil.NotNull(timelineRecord, nameof(timelineRecord));
|
ArgUtil.NotNull(timelineRecord, nameof(timelineRecord));
|
||||||
ArgUtil.NotEmpty(timelineRecord.Id, nameof(timelineRecord.Id));
|
ArgUtil.NotEmpty(timelineRecord.Id, nameof(timelineRecord.Id));
|
||||||
|
|||||||
@@ -66,11 +66,6 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public async Task ConnectAsync(Uri serverUrl, VssCredentials credentials)
|
public async Task ConnectAsync(Uri serverUrl, VssCredentials credentials)
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var createGenericConnection = EstablishVssConnection(serverUrl, credentials, TimeSpan.FromSeconds(100));
|
var createGenericConnection = EstablishVssConnection(serverUrl, credentials, TimeSpan.FromSeconds(100));
|
||||||
var createMessageConnection = EstablishVssConnection(serverUrl, credentials, TimeSpan.FromSeconds(60));
|
var createMessageConnection = EstablishVssConnection(serverUrl, credentials, TimeSpan.FromSeconds(60));
|
||||||
var createRequestConnection = EstablishVssConnection(serverUrl, credentials, TimeSpan.FromSeconds(60));
|
var createRequestConnection = EstablishVssConnection(serverUrl, credentials, TimeSpan.FromSeconds(60));
|
||||||
@@ -303,29 +298,18 @@ namespace GitHub.Runner.Common
|
|||||||
|
|
||||||
public Task<TaskAgentJobRequest> RenewAgentRequestAsync(int poolId, long requestId, Guid lockToken, CancellationToken cancellationToken = default(CancellationToken))
|
public Task<TaskAgentJobRequest> RenewAgentRequestAsync(int poolId, long requestId, Guid lockToken, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult(JsonUtility.FromString<TaskAgentJobRequest>("{ lockedUntil: \"" + DateTime.Now.Add(TimeSpan.FromMinutes(5)).ToString("u") + "\" }"));
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection(RunnerConnectionType.JobRequest);
|
CheckConnection(RunnerConnectionType.JobRequest);
|
||||||
return _requestTaskAgentClient.RenewAgentRequestAsync(poolId, requestId, lockToken, cancellationToken: cancellationToken);
|
return _requestTaskAgentClient.RenewAgentRequestAsync(poolId, requestId, lockToken, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<TaskAgentJobRequest> FinishAgentRequestAsync(int poolId, long requestId, Guid lockToken, DateTime finishTime, TaskResult result, CancellationToken cancellationToken = default(CancellationToken))
|
public Task<TaskAgentJobRequest> FinishAgentRequestAsync(int poolId, long requestId, Guid lockToken, DateTime finishTime, TaskResult result, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
{
|
{
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
return Task.FromResult<TaskAgentJobRequest>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckConnection(RunnerConnectionType.JobRequest);
|
CheckConnection(RunnerConnectionType.JobRequest);
|
||||||
return _requestTaskAgentClient.FinishAgentRequestAsync(poolId, requestId, lockToken, finishTime, result, cancellationToken: cancellationToken);
|
return _requestTaskAgentClient.FinishAgentRequestAsync(poolId, requestId, lockToken, finishTime, result, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<TaskAgentJobRequest> GetAgentRequestAsync(int poolId, long requestId, CancellationToken cancellationToken = default(CancellationToken))
|
public Task<TaskAgentJobRequest> GetAgentRequestAsync(int poolId, long requestId, CancellationToken cancellationToken = default(CancellationToken))
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
CheckConnection(RunnerConnectionType.JobRequest);
|
CheckConnection(RunnerConnectionType.JobRequest);
|
||||||
return _requestTaskAgentClient.GetAgentRequestAsync(poolId, requestId, cancellationToken: cancellationToken);
|
return _requestTaskAgentClient.GetAgentRequestAsync(poolId, requestId, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
@@ -335,7 +319,6 @@ namespace GitHub.Runner.Common
|
|||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
public Task<List<PackageMetadata>> GetPackagesAsync(string packageType, string platform, int top, CancellationToken cancellationToken)
|
public Task<List<PackageMetadata>> GetPackagesAsync(string packageType, string platform, int top, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
CheckConnection(RunnerConnectionType.Generic);
|
CheckConnection(RunnerConnectionType.Generic);
|
||||||
return _genericTaskAgentClient.GetPackagesAsync(packageType, platform, top, cancellationToken: cancellationToken);
|
return _genericTaskAgentClient.GetPackagesAsync(packageType, platform, top, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
_term.WriteLine("| |", ConsoleColor.White);
|
_term.WriteLine("| |", ConsoleColor.White);
|
||||||
_term.WriteLine("--------------------------------------------------------------------------------", ConsoleColor.White);
|
_term.WriteLine("--------------------------------------------------------------------------------", ConsoleColor.White);
|
||||||
|
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
Trace.Info(nameof(ConfigureAsync));
|
Trace.Info(nameof(ConfigureAsync));
|
||||||
if (IsConfigured())
|
if (IsConfigured())
|
||||||
{
|
{
|
||||||
@@ -397,7 +396,6 @@ namespace GitHub.Runner.Listener.Configuration
|
|||||||
|
|
||||||
public async Task UnconfigureAsync(CommandSettings command)
|
public async Task UnconfigureAsync(CommandSettings command)
|
||||||
{
|
{
|
||||||
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
|
|
||||||
string currentAction = string.Empty;
|
string currentAction = string.Empty;
|
||||||
|
|
||||||
_term.WriteSection("Runner removal");
|
_term.WriteSection("Runner removal");
|
||||||
|
|||||||
@@ -367,8 +367,6 @@ namespace GitHub.Runner.Listener
|
|||||||
ArgUtil.NotNullOrEmpty(pipeHandleOut, nameof(pipeHandleOut));
|
ArgUtil.NotNullOrEmpty(pipeHandleOut, nameof(pipeHandleOut));
|
||||||
ArgUtil.NotNullOrEmpty(pipeHandleIn, nameof(pipeHandleIn));
|
ArgUtil.NotNullOrEmpty(pipeHandleIn, nameof(pipeHandleIn));
|
||||||
|
|
||||||
if (HostContext.RunMode == RunMode.Normal)
|
|
||||||
{
|
|
||||||
// Save STDOUT from worker, worker will use STDOUT report unhandle exception.
|
// Save STDOUT from worker, worker will use STDOUT report unhandle exception.
|
||||||
processInvoker.OutputDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stdout)
|
processInvoker.OutputDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stdout)
|
||||||
{
|
{
|
||||||
@@ -392,12 +390,6 @@ namespace GitHub.Runner.Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
processInvoker.OutputDataReceived += (object sender, ProcessDataReceivedEventArgs e) => Console.WriteLine(e.Data);
|
|
||||||
processInvoker.ErrorDataReceived += (object sender, ProcessDataReceivedEventArgs e) => Console.WriteLine(e.Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the child process.
|
// Start the child process.
|
||||||
HostContext.WritePerfCounter("StartingWorkerProcess");
|
HostContext.WritePerfCounter("StartingWorkerProcess");
|
||||||
@@ -724,11 +716,6 @@ namespace GitHub.Runner.Listener
|
|||||||
private async Task CompleteJobRequestAsync(int poolId, Pipelines.AgentJobRequestMessage message, Guid lockToken, TaskResult result, string detailInfo = null)
|
private async Task CompleteJobRequestAsync(int poolId, Pipelines.AgentJobRequestMessage message, Guid lockToken, TaskResult result, string detailInfo = null)
|
||||||
{
|
{
|
||||||
Trace.Entering();
|
Trace.Entering();
|
||||||
if (HostContext.RunMode == RunMode.Local)
|
|
||||||
{
|
|
||||||
_localRunJobResult.Value[message.RequestId] = result;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PlanUtil.GetFeatures(message.Plan).HasFlag(PlanFeatures.JobCompletedPlanEvent))
|
if (PlanUtil.GetFeatures(message.Plan).HasFlag(PlanFeatures.JobCompletedPlanEvent))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user