in src/WebJobs.Script/Workers/WorkerConcurrencyManager.cs [61:107]
public Task StartAsync(CancellationToken cancellationToken)
{
string workerRuntime = _environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime);
if (!string.IsNullOrEmpty(workerRuntime))
{
// the feature applies only to "node","powershell","python"
workerRuntime = workerRuntime.ToLower();
if (workerRuntime == RpcWorkerConstants.NodeLanguageWorkerName
|| workerRuntime == RpcWorkerConstants.PowerShellLanguageWorkerName
|| workerRuntime == RpcWorkerConstants.PythonLanguageWorkerName)
{
_functionInvocationDispatcher = _functionInvocationDispatcherFactory.GetFunctionDispatcher();
if (_functionInvocationDispatcher is HttpFunctionInvocationDispatcher)
{
_logger.LogDebug($"Http dynamic worker concurrency is not supported.");
return Task.CompletedTask;
}
if (!string.IsNullOrEmpty(_environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionsWorkerProcessCountSettingName)))
{
return Task.CompletedTask;
}
if (_environment.IsWorkerDynamicConcurrencyEnabled())
{
_logger.LogDebug($"Dynamic worker concurrency monitoring is starting by app setting.");
Activate();
}
else if (_functionsHostingConfigOptionsMonitor.CurrentValue != null && _functionsHostingConfigOptionsMonitor.CurrentValue.FunctionsWorkerDynamicConcurrencyEnabled)
{
_logger.LogDebug($"Dynamic worker concurrency monitoring is starting by hosting config.");
Activate();
_hostingConfigOnChange = _functionsHostingConfigOptionsMonitor.OnChange(async (newOptions) =>
{
if (!newOptions.FunctionsWorkerDynamicConcurrencyEnabled)
{
// There is a known issue when OnChange fires twice: https://github.com/dotnet/aspnetcore/issues/2542
// Lets make sure we stopped the app once
await _stopApplication();
}
});
}
}
}
return Task.CompletedTask;
}