Skip to content

Commit f0b4858

Browse files
authored
Revert "Add startup logs (#5146)" (#5164)
This reverts commit cf40d87 and resolved conflicts
1 parent e66b765 commit f0b4858

File tree

3 files changed

+54
-72
lines changed

3 files changed

+54
-72
lines changed

src/WebJobs.Script.WebHost/App_Start/WebHostResolver.cs

Lines changed: 54 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public sealed class WebHostResolver : IDisposable
3535
private ILoggerFactory _defaultLoggerFactory;
3636
private TraceWriter _defaultTraceWriter;
3737
private Timer _specializationTimer;
38-
private ILogger _logger;
3938

4039
public WebHostResolver(ScriptSettingsManager settingsManager, ISecretManagerFactory secretManagerFactory, IScriptEventManager eventManager)
4140
{
@@ -124,86 +123,74 @@ public WebHookReceiverManager GetWebHookReceiverManager(WebHostSettings settings
124123
/// </summary>
125124
internal void EnsureInitialized(WebHostSettings settings)
126125
{
127-
ILoggerFactory defaultLoggerFactory = GetDefaultLoggerFactory(settings);
128-
_logger = defaultLoggerFactory.CreateLogger(ScriptConstants.LogCategoryHostStartup);
129-
try
126+
lock (_syncLock)
130127
{
131-
lock (_syncLock)
128+
// Determine whether we should do normal or standby initialization
129+
if (!WebScriptHostManager.InStandbyMode)
132130
{
133-
// Determine whether we should do normal or standby initialization
134-
if (!WebScriptHostManager.InStandbyMode)
131+
// We're not in standby mode. There are two cases to consider:
132+
// 1) We _were_ in standby mode and now we're ready to specialize
133+
// 2) We're doing non-specialization normal initialization
134+
if (_activeHostManager == null &&
135+
(_standbyHostManager == null || (_settingsManager.ContainerReady && _settingsManager.ConfigurationReady)))
135136
{
136-
// We're not in standby mode. There are two cases to consider:
137-
// 1) We _were_ in standby mode and now we're ready to specialize
138-
// 2) We're doing non-specialization normal initialization
139-
if (_activeHostManager == null &&
140-
(_standbyHostManager == null || (_settingsManager.ContainerReady && _settingsManager.ConfigurationReady)))
141-
{
142-
_logger.LogDebug("Not in standby mode.Initializing host");
137+
_specializationTimer?.Dispose();
138+
_specializationTimer = null;
143139

144-
_specializationTimer?.Dispose();
145-
_specializationTimer = null;
140+
_activeScriptHostConfig = CreateScriptHostConfiguration(settings);
141+
var defaultLoggerFactory = GetDefaultLoggerFactory(settings);
142+
_activeHostManager = new WebScriptHostManager(_activeScriptHostConfig, _secretManagerFactory, _eventManager, _settingsManager, settings, defaultLoggerFactory);
143+
_activeReceiverManager = new WebHookReceiverManager(_activeHostManager.SecretManager);
144+
InitializeFileSystem(_settingsManager.FileSystemIsReadOnly);
146145

147-
_activeScriptHostConfig = CreateScriptHostConfiguration(settings);
148-
_activeHostManager = new WebScriptHostManager(_activeScriptHostConfig, _secretManagerFactory, _eventManager, _settingsManager, settings, defaultLoggerFactory);
149-
_activeReceiverManager = new WebHookReceiverManager(_activeHostManager.SecretManager);
150-
InitializeFileSystem(_settingsManager.FileSystemIsReadOnly);
151-
152-
if (_standbyHostManager != null)
153-
{
154-
// we're starting the one and only one
155-
// standby mode specialization
156-
_activeScriptHostConfig.TraceWriter.Info(Resources.HostSpecializationTrace);
146+
if (_standbyHostManager != null)
147+
{
148+
// we're starting the one and only one
149+
// standby mode specialization
150+
_activeScriptHostConfig.TraceWriter.Info(Resources.HostSpecializationTrace);
157151

158-
// After specialization, we need to ensure that custom timezone
159-
// settings configured by the user (WEBSITE_TIME_ZONE) are honored.
160-
// DateTime caches timezone information, so we need to clear the cache.
161-
TimeZoneInfo.ClearCachedData();
152+
// After specialization, we need to ensure that custom timezone
153+
// settings configured by the user (WEBSITE_TIME_ZONE) are honored.
154+
// DateTime caches timezone information, so we need to clear the cache.
155+
TimeZoneInfo.ClearCachedData();
162156

163-
// ensure we reinitialize hostname after specialization
164-
HostNameProvider.Reset();
165-
}
157+
// ensure we reinitialize hostname after specialization
158+
HostNameProvider.Reset();
159+
}
166160

167-
if (_standbyHostManager != null)
168-
{
169-
_standbyHostManager.Stop();
170-
_standbyHostManager.Dispose();
171-
}
172-
_standbyReceiverManager?.Dispose();
173-
_standbyScriptHostConfig = null;
174-
_standbyHostManager = null;
175-
_standbyReceiverManager = null;
161+
if (_standbyHostManager != null)
162+
{
163+
_standbyHostManager.Stop();
164+
_standbyHostManager.Dispose();
176165
}
166+
_standbyReceiverManager?.Dispose();
167+
_standbyScriptHostConfig = null;
168+
_standbyHostManager = null;
169+
_standbyReceiverManager = null;
177170
}
178-
else
171+
}
172+
else
173+
{
174+
// We're in standby (placeholder) mode. Initialize the standby services.
175+
if (_standbyHostManager == null)
179176
{
180-
// We're in standby (placeholder) mode. Initialize the standby services.
181-
if (_standbyHostManager == null)
182-
{
183-
_logger.LogDebug("In standby mode");
184-
var standbySettings = CreateStandbySettings(settings);
185-
_standbyScriptHostConfig = CreateScriptHostConfiguration(standbySettings, true);
186-
_standbyHostManager = new WebScriptHostManager(_standbyScriptHostConfig, _secretManagerFactory, _eventManager, _settingsManager, standbySettings, defaultLoggerFactory);
187-
_standbyReceiverManager = new WebHookReceiverManager(_standbyHostManager.SecretManager);
188-
189-
InitializeFileSystem(_settingsManager.FileSystemIsReadOnly);
190-
StandbyManager.Initialize(_standbyScriptHostConfig);
191-
192-
// start a background timer to identify when specialization happens
193-
// specialization usually happens via an http request (e.g. scale controller
194-
// ping) but this timer is started as well to handle cases where we
195-
// might not receive a request
196-
_specializationTimer = new Timer(OnSpecializationTimerTick, settings, 1000, 1000);
197-
}
177+
var standbySettings = CreateStandbySettings(settings);
178+
_standbyScriptHostConfig = CreateScriptHostConfiguration(standbySettings, true);
179+
var defaultLoggerFactory = GetDefaultLoggerFactory(settings);
180+
_standbyHostManager = new WebScriptHostManager(_standbyScriptHostConfig, _secretManagerFactory, _eventManager, _settingsManager, standbySettings, defaultLoggerFactory);
181+
_standbyReceiverManager = new WebHookReceiverManager(_standbyHostManager.SecretManager);
182+
183+
InitializeFileSystem(_settingsManager.FileSystemIsReadOnly);
184+
StandbyManager.Initialize(_standbyScriptHostConfig);
185+
186+
// start a background timer to identify when specialization happens
187+
// specialization usually happens via an http request (e.g. scale controller
188+
// ping) but this timer is started as well to handle cases where we
189+
// might not receive a request
190+
_specializationTimer = new Timer(OnSpecializationTimerTick, settings, 1000, 1000);
198191
}
199192
}
200193
}
201-
catch (Exception initializationException)
202-
{
203-
var errorEventId = new EventId(103, "HostInitializationError");
204-
_logger.LogError(errorEventId, initializationException, "Failed to initialize host");
205-
throw;
206-
}
207194
}
208195

209196
internal static WebHostSettings CreateStandbySettings(WebHostSettings settings)

src/WebJobs.Script.WebHost/WebScriptHostManager.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ private async void OnSyncTimerTick(object state)
453453

454454
private void InitializeHttp()
455455
{
456-
_logger.LogDebug("Initializing HttpRequestManager");
457456
// get the registered http configuration from the extension registry
458457
var extensions = Instance.ScriptConfig.HostConfig.GetService<IExtensionRegistry>();
459458
var httpConfig = extensions.GetExtensions<IExtensionConfigProvider>().OfType<HttpExtensionConfiguration>().Single();
@@ -465,12 +464,10 @@ private void InitializeHttp()
465464
// since the request manager is created based on configurable
466465
// settings, it has to be recreated when host config changes
467466
_httpRequestManager = new WebScriptHostRequestManager(httpConfig, PerformanceManager, _metricsLogger, _config.TraceWriter);
468-
_logger.LogDebug("Initialized HttpRequestManager");
469467
}
470468

471469
private void InitializeHttpFunctions(IEnumerable<FunctionDescriptor> functions, HttpExtensionConfiguration httpConfig)
472470
{
473-
_logger.LogDebug("Initializing HttpFunctions");
474471
// we must initialize the route factory here AFTER full configuration
475472
// has been resolved so we apply any route prefix customizations
476473
var functionHttpRouteFactory = new HttpRouteFactory(httpConfig.RoutePrefix);
@@ -489,7 +486,6 @@ private void InitializeHttpFunctions(IEnumerable<FunctionDescriptor> functions,
489486
var httpRouteFactory = function.Metadata.IsProxy ? proxyHttpRouteFactory : functionHttpRouteFactory;
490487
httpRouteFactory.TryAddRoute(_httpRoutes, function);
491488
}
492-
_logger.LogDebug("Initialized HttpFunctions");
493489
}
494490

495491
public override void Shutdown(bool hard = false)

src/WebJobs.Script/ScriptConstants.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public static class ScriptConstants
4545
public const string LogCategoryKeysController = "Host.Controllers.Keys";
4646
public const string LogCategoryKeys = "Host.Keys";
4747
public const string LogCategoryHostGeneral = "Host.General";
48-
public const string LogCategoryHostStartup = "Host.Startup";
4948

5049
// Define all system parameters we inject with a prefix to avoid collisions
5150
// with user parameters

0 commit comments

Comments
 (0)