Skip to content

Commit 2d2b276

Browse files
authored
Log when FunctionDispatcher is initialized. (#6230) (#6383)
1 parent 24597df commit 2d2b276

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/WebJobs.Script/Workers/Http/HttpFunctionInvocationDispatcher.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@ public HttpFunctionInvocationDispatcher(IOptions<ScriptJobHostOptions> scriptHos
6565

6666
internal Task InitializeHttpWorkerChannelAsync(int attemptCount, CancellationToken cancellationToken = default)
6767
{
68-
// TODO: Add process managment for http invoker
6968
_httpWorkerChannel = _httpWorkerChannelFactory.Create(_scriptOptions.RootScriptPath, _metricsLogger, attemptCount);
7069
_httpWorkerChannel.StartWorkerProcessAsync(cancellationToken).ContinueWith(workerInitTask =>
7170
{
7271
if (workerInitTask.IsCompleted)
7372
{
7473
_logger.LogDebug("Adding http worker channel. workerId:{id}", _httpWorkerChannel.Id);
75-
State = FunctionInvocationDispatcherState.Initialized;
74+
SetFunctionDispatcherStateToInitializedAndLog();
7675
}
7776
else
7877
{
@@ -82,6 +81,12 @@ internal Task InitializeHttpWorkerChannelAsync(int attemptCount, CancellationTok
8281
return Task.CompletedTask;
8382
}
8483

84+
private void SetFunctionDispatcherStateToInitializedAndLog()
85+
{
86+
State = FunctionInvocationDispatcherState.Initialized;
87+
_logger.LogInformation("Worker process started and initialized.");
88+
}
89+
8590
public async Task InitializeAsync(IEnumerable<FunctionMetadata> functions, CancellationToken cancellationToken = default)
8691
{
8792
cancellationToken.ThrowIfCancellationRequested();

src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ internal Task InitializeJobhostLanguageWorkerChannelAsync(int attemptCount)
122122
{
123123
_logger.LogDebug("Adding jobhost language worker channel for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
124124
rpcWorkerChannel.SendFunctionLoadRequests(_managedDependencyOptions.Value);
125-
State = FunctionInvocationDispatcherState.Initialized;
125+
SetFunctionDispatcherStateToInitializedAndLog();
126126
}
127127
else
128128
{
@@ -132,6 +132,13 @@ internal Task InitializeJobhostLanguageWorkerChannelAsync(int attemptCount)
132132
return Task.CompletedTask;
133133
}
134134

135+
private void SetFunctionDispatcherStateToInitializedAndLog()
136+
{
137+
State = FunctionInvocationDispatcherState.Initialized;
138+
// Do not change this log message. Vs Code relies on this to figure out when to attach debuger to the worker process.
139+
_logger.LogInformation("Worker process started and initialized.");
140+
}
141+
135142
internal async void InitializeWebhostLanguageWorkerChannel()
136143
{
137144
_logger.LogDebug("Creating new webhost language worker channel for runtime:{workerRuntime}.", _workerRuntime);
@@ -207,7 +214,7 @@ public async Task InitializeAsync(IEnumerable<FunctionMetadata> functions, Cance
207214
}
208215
}
209216
StartWorkerProcesses(webhostLanguageWorkerChannels.Count(), InitializeWebhostLanguageWorkerChannel);
210-
State = FunctionInvocationDispatcherState.Initialized;
217+
SetFunctionDispatcherStateToInitializedAndLog();
211218
}
212219
else
213220
{

0 commit comments

Comments
 (0)