@@ -49,7 +49,7 @@ public class ScriptHost : JobHost, IScriptJobHost
49
49
private readonly IMetricsLogger _metricsLogger = null ;
50
50
private readonly string _hostLogPath ;
51
51
private readonly Stopwatch _stopwatch = new Stopwatch ( ) ;
52
- private readonly string _language ;
52
+ private readonly string _currentRuntimelanguage ;
53
53
private readonly IOptions < JobHostOptions > _hostOptions ;
54
54
private readonly ScriptTypeLocator _typeLocator ;
55
55
private readonly IDebugStateProvider _debugManager ;
@@ -120,7 +120,7 @@ public ScriptHost(IOptions<JobHostOptions> options,
120
120
121
121
_hostLogPath = Path . Combine ( ScriptOptions . RootLogPath , "Host" ) ;
122
122
123
- _language = _settingsManager . Configuration [ LanguageWorkerConstants . FunctionWorkerRuntimeSettingName ] ;
123
+ _currentRuntimelanguage = _settingsManager . Configuration [ LanguageWorkerConstants . FunctionWorkerRuntimeSettingName ] ;
124
124
125
125
_loggerFactory = loggerFactory ;
126
126
_logger = loggerFactory . CreateLogger ( LogCategories . Startup ) ;
@@ -251,10 +251,13 @@ public async Task InitializeAsync()
251
251
using ( _metricsLogger . LatencyEvent ( MetricEventNames . HostStartupLatency ) )
252
252
{
253
253
PreInitialize ( ) ;
254
- await InitializeWorkersAsync ( ) ;
255
254
256
255
// Generate Functions
257
256
IEnumerable < FunctionMetadata > functions = GetFunctionsMetadata ( ) ;
257
+ if ( Utility . ShouldInitiliazeLanguageWorkers ( functions , _currentRuntimelanguage ) )
258
+ {
259
+ await InitializeWorkersAsync ( ) ;
260
+ }
258
261
var directTypes = GetDirectTypes ( functions ) ;
259
262
InitializeFunctionDescriptors ( functions ) ;
260
263
GenerateFunctions ( directTypes ) ;
@@ -430,16 +433,16 @@ private void GenerateFunctions(IEnumerable<Type> directTypes)
430
433
/// </summary>
431
434
internal void InitializeFunctionDescriptors ( IEnumerable < FunctionMetadata > functionMetadata )
432
435
{
433
- if ( string . IsNullOrEmpty ( _language ) )
436
+ if ( string . IsNullOrEmpty ( _currentRuntimelanguage ) )
434
437
{
435
438
_logger . LogTrace ( "Adding Function descriptor providers for all languages." ) ;
436
439
_descriptorProviders . Add ( new DotNetFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _metricsLogger , _loggerFactory ) ) ;
437
440
_descriptorProviders . Add ( new WorkerFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _functionDispatcher , _loggerFactory ) ) ;
438
441
}
439
442
else
440
443
{
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 ) )
443
446
{
444
447
_descriptorProviders . Add ( new DotNetFunctionDescriptorProvider ( this , ScriptOptions , _bindingProviders , _metricsLogger , _loggerFactory ) ) ;
445
448
}
@@ -496,7 +499,7 @@ private async Task InitializeWorkersAsync()
496
499
attemptCount ) ;
497
500
} ;
498
501
499
- _functionDispatcher = new FunctionDispatcher ( EventManager , server , channelFactory , _workerConfigs , _language ) ;
502
+ _functionDispatcher = new FunctionDispatcher ( EventManager , server , channelFactory , _workerConfigs , _currentRuntimelanguage ) ;
500
503
501
504
_eventSubscriptions . Add ( EventManager . OfType < WorkerProcessErrorEvent > ( )
502
505
. Subscribe ( evt =>
@@ -657,7 +660,7 @@ internal Collection<FunctionDescriptor> GetFunctionDescriptors(IEnumerable<Funct
657
660
Collection < FunctionDescriptor > functionDescriptors = new Collection < FunctionDescriptor > ( ) ;
658
661
var httpFunctions = new Dictionary < string , HttpTriggerAttribute > ( ) ;
659
662
660
- if ( ! Utility . IsSingleLanguage ( functions , _language ) )
663
+ if ( ! Utility . IsSingleLanguage ( functions , _currentRuntimelanguage ) )
661
664
{
662
665
_logger . LogError ( $ "Found functions with more than one language. Select a language for your function app by specifying { LanguageWorkerConstants . FunctionWorkerRuntimeSettingName } AppSetting") ;
663
666
return functionDescriptors ;
0 commit comments