Skip to content

Commit cb31e70

Browse files
committed
Host specialization improvements
1 parent b1ab899 commit cb31e70

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ internal void EnsureInitialized(WebHostSettings settings)
111111

112112
if (_standbyHostManager != null)
113113
{
114-
// we're undergoing the one and only one
114+
// we're starting the one and only one
115115
// standby mode specialization
116116
_activeScriptHostConfig.TraceWriter.Info(Resources.HostSpecializationTrace);
117+
118+
// After specialization, we need to ensure that custom timezone
119+
// settings configured by the user (WEBSITE_TIME_ZONE) are honored.
120+
// DateTime caches timezone information, so we need to clear the cache.
121+
TimeZoneInfo.ClearCachedData();
117122
}
118123

119124
_standbyHostManager?.Dispose();

src/WebJobs.Script.WebHost/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/WebJobs.Script.WebHost/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@
260260
}</value>
261261
</data>
262262
<data name="HostSpecializationTrace" xml:space="preserve">
263-
<value>Host has been specialized</value>
263+
<value>Starting host specialization</value>
264264
</data>
265265
<data name="SwaggerFileDeleteError" xml:space="preserve">
266266
<value>Error deleting Swagger document</value>

test/WebJobs.Script.Tests.Integration/Host/StandbyManagerTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public async Task StandbyMode_EndToEnd()
8383
IsSelfHost = true,
8484
LogPath = Path.Combine(testRootPath, "Logs"),
8585
SecretsPath = Path.Combine(testRootPath, "Secrets"),
86+
ScriptPath = testRootPath,
8687
TraceWriter = traceWriter
8788
};
8889
WebApiConfig.Register(httpConfig, _settingsManager, webHostSettings);
@@ -111,16 +112,24 @@ public async Task StandbyMode_EndToEnd()
111112
responseBody = await response.Content.ReadAsStringAsync();
112113
Assert.Equal("WarmUp complete.", responseBody);
113114

115+
// Now specialize the host
116+
ScriptSettingsManager.Instance.SetSetting(EnvironmentSettingNames.AzureWebsitePlaceholderMode, "0");
117+
request = new HttpRequestMessage(HttpMethod.Get, "api/dne");
118+
response = await httpClient.SendAsync(request);
119+
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
120+
114121
httpServer.Dispose();
115122
httpClient.Dispose();
116123

117124
await Task.Delay(2000);
118125

119126
// verify logs
120127
string[] logLines = traceWriter.Traces.Select(p => p.Message).ToArray();
128+
string text = string.Join(Environment.NewLine, logLines);
121129
Assert.Equal(2, logLines.Count(p => p.Contains("Host is in standby mode")));
122130
Assert.Equal(1, logLines.Count(p => p.Contains("Stopping Host")));
123131
Assert.Equal(2, logLines.Count(p => p.Contains("Executed 'Functions.WarmUp' (Succeeded")));
132+
Assert.Equal(1, logLines.Count(p => p.Contains("Starting host specialization")));
124133
}
125134
}
126135
}

0 commit comments

Comments
 (0)