@@ -49,7 +49,7 @@ public class ScriptHost : JobHost, IScriptJobHost
4949 private readonly IMetricsLogger _metricsLogger = null ;
5050 private readonly string _hostLogPath ;
5151 private readonly Stopwatch _stopwatch = new Stopwatch ( ) ;
52- private readonly string _language ;
52+ private readonly string _currentRuntimelanguage ;
5353 private readonly IOptions < JobHostOptions > _hostOptions ;
5454 private readonly ScriptTypeLocator _typeLocator ;
5555 private readonly IDebugStateProvider _debugManager ;
@@ -120,7 +120,7 @@ public ScriptHost(IOptions<JobHostOptions> options,
120120
121121 _hostLogPath = Path . Combine ( ScriptOptions . RootLogPath , "Host" ) ;
122122
123- _language = _settingsManager . Configuration [ LanguageWorkerConstants . FunctionWorkerRuntimeSettingName ] ;
123+ _currentRuntimelanguage = _settingsManager . Configuration [ LanguageWorkerConstants . FunctionWorkerRuntimeSettingName ] ;
124124
125125 _loggerFactory = loggerFactory ;
126126 _logger = loggerFactory . CreateLogger ( LogCategories . Startup ) ;
@@ -251,10 +251,13 @@ public async Task InitializeAsync()
251251 using ( _metricsLogger . LatencyEvent ( MetricEventNames . HostStartupLatency ) )
252252 {
253253 PreInitialize ( ) ;
254- await InitializeWorkersAsync ( ) ;
255254
256255 // Generate Functions
257256 IEnumerable < FunctionMetadata > functions = GetFunctionsMetadata ( ) ;
257+ if ( Utility . ShouldInitiliazeLanguageWorkers ( functions , _currentRuntimelanguage ) )
258+ {
259+ await InitializeWorkersAsync ( ) ;
260+ }
258261 var directTypes = GetDirectTypes ( functions ) ;
259262 InitializeFunctionDescriptors ( functions ) ;
260263 GenerateFunctions ( directTypes ) ;
@@ -430,16 +433,16 @@ private void GenerateFunctions(IEnumerable<Type> directTypes)
430433 /// </summary>
431434 internal void InitializeFunctionDescriptors ( IEnumerable < FunctionMetadata > functionMetadata )
432435 {
433- if ( string . IsNullOrEmpty ( _language ) )
436+ if ( string . IsNullOrEmpty ( _currentRuntimelanguage ) )
434437 {
435438 _logger . LogTrace ( "Adding Function descriptor providers for all languages." ) ;
436439 _descriptorProviders . Add ( new DotNetFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _metricsLogger , _loggerFactory ) ) ;
437440 _descriptorProviders . Add ( new WorkerFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _functionDispatcher , _loggerFactory ) ) ;
438441 }
439442 else
440443 {
441- _logger . LogTrace ( $ "Adding Function descriptor provider for language { _language } .") ;
442- if ( string . Equals ( _language , LanguageWorkerConstants . DotNetLanguageWorkerName , StringComparison . OrdinalIgnoreCase ) )
444+ _logger . LogTrace ( $ "Adding Function descriptor provider for language { _currentRuntimelanguage } .") ;
445+ if ( string . Equals ( _currentRuntimelanguage , LanguageWorkerConstants . DotNetLanguageWorkerName , StringComparison . OrdinalIgnoreCase ) )
443446 {
444447 _descriptorProviders . Add ( new DotNetFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _metricsLogger , _loggerFactory ) ) ;
445448 }
@@ -496,7 +499,7 @@ private async Task InitializeWorkersAsync()
496499 attemptCount ) ;
497500 } ;
498501
499- _functionDispatcher = new FunctionDispatcher ( EventManager , server , channelFactory , _workerConfigs , _language ) ;
502+ _functionDispatcher = new FunctionDispatcher ( EventManager , server , channelFactory , _workerConfigs , _currentRuntimelanguage ) ;
500503
501504 _eventSubscriptions . Add ( EventManager . OfType < WorkerProcessErrorEvent > ( )
502505 . Subscribe ( evt =>
@@ -657,7 +660,7 @@ internal Collection<FunctionDescriptor> GetFunctionDescriptors(IEnumerable<Funct
657660 Collection < FunctionDescriptor > functionDescriptors = new Collection < FunctionDescriptor > ( ) ;
658661 var httpFunctions = new Dictionary < string , HttpTriggerAttribute > ( ) ;
659662
660- if ( ! Utility . IsSingleLanguage ( functions , _language ) )
663+ if ( ! Utility . IsSingleLanguage ( functions , _currentRuntimelanguage ) )
661664 {
662665 _logger . LogError ( $ "Found functions with more than one language. Select a language for your function app by specifying { LanguageWorkerConstants . FunctionWorkerRuntimeSettingName } AppSetting") ;
663666 return functionDescriptors ;
0 commit comments