/// <summary> /// Performs all required initialization on the host. /// Must be called before the host is started. /// </summary> public async Task InitializeAsync(CancellationToken cancellationToken = default) { _stopwatch.Start(); using (_metricsLogger.LatencyEvent(MetricEventNames.HostStartupLatency)) { PreInitialize(); HostInitializing?.Invoke(this, EventArgs.Empty); // Generate Functions IEnumerable <FunctionMetadata> functionMetadataList = GetFunctionsMetadata(); _workerRuntime = _workerRuntime ?? Utility.GetWorkerRuntime(functionMetadataList); if (!_environment.IsPlaceholderModeEnabled()) { // Appending the runtime version is currently only enabled for linux consumption. // This will be eventually enabled for Windows Consumption as well. string runtimeStack = GetPreciseRuntimeStack(_workerRuntime); _metricsLogger.LogEvent(string.Format(MetricEventNames.HostStartupRuntimeLanguage, runtimeStack)); } var directTypes = GetDirectTypes(functionMetadataList); await InitializeFunctionDescriptorsAsync(functionMetadataList); // Initialize worker function invocation dispatcher only for valid functions after creating function descriptors await _functionDispatcher.InitializeAsync(Utility.GetValidFunctions(functionMetadataList, Functions), cancellationToken); GenerateFunctions(directTypes); CleanupFileSystem(); } }
/// <summary> /// Performs all required initialization on the host. /// Must be called before the host is started. /// </summary> public async Task InitializeAsync() { _stopwatch.Start(); using (_metricsLogger.LatencyEvent(MetricEventNames.HostStartupLatency)) { PreInitialize(); HostInitializing?.Invoke(this, EventArgs.Empty); // Generate Functions IEnumerable <FunctionMetadata> functions = GetFunctionsMetadata(); _workerRuntime = _workerRuntime ?? Utility.GetWorkerRuntime(functions); if (!_environment.IsPlaceholderModeEnabled()) { _metricsLogger.LogEvent(string.Format(MetricEventNames.HostStartupRuntimeLanguage, _workerRuntime)); } // Initialize language worker function dispatcher await _functionDispatcher.InitializeAsync(functions); var directTypes = GetDirectTypes(functions); await InitializeFunctionDescriptorsAsync(functions); GenerateFunctions(directTypes); CleanupFileSystem(); } }
/// <summary> /// Performs all required initialization on the host. /// Must be called before the host is started. /// </summary> public async Task InitializeAsync() { _stopwatch.Start(); if (!_environment.IsPlaceholderModeEnabled()) { string runtimeLanguage = string.IsNullOrEmpty(_workerRuntime) ? "none" : _workerRuntime; _metricsLogger.LogEvent(string.Format(MetricEventNames.HostStartupRuntimeLanguage, runtimeLanguage)); } using (_metricsLogger.LatencyEvent(MetricEventNames.HostStartupLatency)) { PreInitialize(); HostInitializing?.Invoke(this, EventArgs.Empty); // Generate Functions IEnumerable <FunctionMetadata> functions = GetFunctionsMetadata(); _workerRuntime = _workerRuntime ?? Utility.GetWorkerRuntime(functions); if (Utility.ShouldInitializeFunctionDispatcher(_environment, functions, _workerRuntime)) { _functionDispatcher.CreateWorkerState(_workerRuntime); } var directTypes = GetDirectTypes(functions); await InitializeFunctionDescriptorsAsync(functions); GenerateFunctions(directTypes); CleanupFileSystem(); } }
private void OnHostInitializing(object sender, EventArgs e) { // we check host health before starting to avoid starting // the host when connection or other issues exist IsHostHealthy(throwWhenUnhealthy: true); // We invoke any registered event delegates during Host Initialization HostInitializing?.Invoke(sender, e); }
/// <summary> /// Performs all required initialization on the host. /// Must be called before the host is started. /// </summary> public async Task InitializeAsync(CancellationToken cancellationToken = default) { _stopwatch = ValueStopwatch.StartNew(); using (_metricsLogger.LatencyEvent(MetricEventNames.HostStartupLatency)) { PreInitialize(); HostInitializing?.Invoke(this, EventArgs.Empty); _workerRuntime = _workerRuntime ?? _environment.GetEnvironmentVariable(EnvironmentSettingNames.FunctionWorkerRuntime); // get worker config information and check to see if worker should index or not var workerConfigs = _languageWorkerOptions.Value.WorkerConfigs; bool workerIndexing = Utility.CanWorkerIndex(workerConfigs, _environment); // Generate Functions IEnumerable <FunctionMetadata> functionMetadataList = GetFunctionsMetadata(workerIndexing); if (!_environment.IsPlaceholderModeEnabled()) { string runtimeStack = _workerRuntime; if (!string.IsNullOrEmpty(runtimeStack)) { // Appending the runtime version is currently only enabled for linux consumption. This will be eventually enabled for // Windows Consumption as well. string runtimeVersion = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName); if (!string.IsNullOrEmpty(runtimeVersion)) { runtimeStack = string.Concat(runtimeStack, "-", runtimeVersion); } } _metricsLogger.LogEvent(string.Format(MetricEventNames.HostStartupRuntimeLanguage, Sanitizer.Sanitize(runtimeStack))); Utility.LogAutorestGeneratedJsonIfExists(ScriptOptions.RootScriptPath, _logger); } IsFunctionDataCacheEnabled = GetIsFunctionDataCacheEnabled(); await InitializeFunctionDescriptorsAsync(functionMetadataList, cancellationToken); if (!workerIndexing) { // Initialize worker function invocation dispatcher only for valid functions after creating function descriptors // Dispatcher not needed for codeless function. // Disptacher needed for non-dotnet codeless functions var filteredFunctionMetadata = functionMetadataList.Where(m => !Utility.IsCodelessDotNetLanguageFunction(m)); await _functionDispatcher.InitializeAsync(Utility.GetValidFunctions(filteredFunctionMetadata, Functions), cancellationToken); } GenerateFunctions(); ScheduleFileSystemCleanup(); } }
/// <summary> /// Performs all required initialization on the host. /// Must be called before the host is started. /// </summary> public async Task InitializeAsync(CancellationToken cancellationToken = default) { _stopwatch.Start(); using (_metricsLogger.LatencyEvent(MetricEventNames.HostStartupLatency)) { PreInitialize(); HostInitializing?.Invoke(this, EventArgs.Empty); // Generate Functions IEnumerable <FunctionMetadata> functionMetadataList = GetFunctionsMetadata(); _workerRuntime = _workerRuntime ?? Utility.GetWorkerRuntime(functionMetadataList); if (!_environment.IsPlaceholderModeEnabled()) { string runtimeStack = _workerRuntime; if (!string.IsNullOrEmpty(runtimeStack)) { // Appending the runtime version is currently only enabled for linux consumption. This will be eventually enabled for // Windows Consumption as well. string runtimeVersion = _environment.GetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName); if (!string.IsNullOrEmpty(runtimeVersion)) { runtimeStack = string.Concat(runtimeStack, "-", runtimeVersion); } } _metricsLogger.LogEvent(string.Format(MetricEventNames.HostStartupRuntimeLanguage, runtimeStack)); Utility.LogAutorestGeneratedJsonIfExists(ScriptOptions.RootScriptPath, _logger); } var directTypes = GetDirectTypes(functionMetadataList); await InitializeFunctionDescriptorsAsync(functionMetadataList, cancellationToken); // Initialize worker function invocation dispatcher only for valid functions after creating function descriptors // Dispatcher not needed for non-proxy codeless function. // Disptacher needed for non-dotnet codeless functions var filteredFunctionMetadata = functionMetadataList.Where(m => m.IsProxy() || !Utility.IsCodelessDotNetLanguageFunction(m)); await _functionDispatcher.InitializeAsync(Utility.GetValidFunctions(filteredFunctionMetadata, Functions), cancellationToken); GenerateFunctions(directTypes); ScheduleFileSystemCleanup(); } }
/// <summary> /// Performs all required initialization on the host. /// Must be called before the host is started. /// </summary> public async Task InitializeAsync() { _stopwatch.Start(); using (_metricsLogger.LatencyEvent(MetricEventNames.HostStartupLatency)) { PreInitialize(); HostInitializing?.Invoke(this, EventArgs.Empty); // Generate Functions IEnumerable <FunctionMetadata> functions = GetFunctionsMetadata(); if (Utility.ShouldInitiliazeLanguageWorkers(functions, _currentRuntimelanguage)) { await InitializeWorkersAsync(); } var directTypes = GetDirectTypes(functions); await InitializeFunctionDescriptorsAsync(functions); GenerateFunctions(directTypes); CleanupFileSystem(); } }