Skip to content

Log when FunctionDispatcher is initialized. #6230

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

Merged
merged 2 commits into from
Jun 17, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ public HttpFunctionInvocationDispatcher(IOptions<ScriptJobHostOptions> scriptHos

internal Task InitializeHttpWorkerChannelAsync(int attemptCount, CancellationToken cancellationToken = default)
{
// TODO: Add process managment for http invoker

_httpWorkerChannel = _httpWorkerChannelFactory.Create(_scriptOptions.RootScriptPath, _metricsLogger, attemptCount);
_httpWorkerChannel.StartWorkerProcessAsync(cancellationToken).ContinueWith(workerInitTask =>
{
if (workerInitTask.IsCompleted)
{
_logger.LogDebug("Adding http worker channel. workerId:{id}", _httpWorkerChannel.Id);
State = FunctionInvocationDispatcherState.Initialized;
SetFunctionDispatcherStateToInitializedAndLog();
}
else
{
Expand All @@ -83,6 +81,12 @@ internal Task InitializeHttpWorkerChannelAsync(int attemptCount, CancellationTok
return Task.CompletedTask;
}

private void SetFunctionDispatcherStateToInitializedAndLog()
{
State = FunctionInvocationDispatcherState.Initialized;
_logger.LogInformation("Worker process started and initialized.");
}

public async Task InitializeAsync(IEnumerable<FunctionMetadata> functions, CancellationToken cancellationToken = default)
{
if (functions == null || !functions.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ internal Task InitializeJobhostLanguageWorkerChannelAsync(int attemptCount)
{
_logger.LogDebug("Adding jobhost language worker channel for runtime: {language}. workerId:{id}", _workerRuntime, rpcWorkerChannel.Id);
rpcWorkerChannel.SendFunctionLoadRequests(_managedDependencyOptions.Value);
State = FunctionInvocationDispatcherState.Initialized;
SetFunctionDispatcherStateToInitializedAndLog();
}
else
{
Expand All @@ -132,6 +132,13 @@ internal Task InitializeJobhostLanguageWorkerChannelAsync(int attemptCount)
return Task.CompletedTask;
}

private void SetFunctionDispatcherStateToInitializedAndLog()
{
State = FunctionInvocationDispatcherState.Initialized;
// Do not change this log message. Vs Code relies on this to figure out when to attach debuger to the worker process.
_logger.LogInformation("Worker process started and initialized.");
}

internal async void InitializeWebhostLanguageWorkerChannel()
{
_logger.LogDebug("Creating new webhost language worker channel for runtime:{workerRuntime}.", _workerRuntime);
Expand Down Expand Up @@ -205,7 +212,7 @@ public async Task InitializeAsync(IEnumerable<FunctionMetadata> functions, Cance
}
}
StartWorkerProcesses(webhostLanguageWorkerChannels.Count(), InitializeWebhostLanguageWorkerChannel);
State = FunctionInvocationDispatcherState.Initialized;
SetFunctionDispatcherStateToInitializedAndLog();
}
else
{
Expand Down