Skip to content

Commit 7c7ac3b

Browse files
committed
Host specialization improvements
1 parent 42a4111 commit 7c7ac3b

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

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

Lines changed: 5 additions & 7 deletions
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
@@ -256,7 +256,7 @@
256256
}</value>
257257
</data>
258258
<data name="HostSpecializationTrace" xml:space="preserve">
259-
<value>Host has been specialized</value>
259+
<value>Starting host specialization</value>
260260
</data>
261261
<data name="TraceAddOrUpdateFunctionSecret" xml:space="preserve">
262262
<value>{0} secret '{1}' for '{2}' {3}.</value>

src/WebJobs.Script.WebHost/WebHostResolver.cs

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

123123
if (_standbyHostManager != null)
124124
{
125-
// we're undergoing the one and only one
125+
// we're starting the one and only one
126126
// standby mode specialization
127127
_activeScriptHostConfig.TraceWriter.Info(Resources.HostSpecializationTrace);
128+
129+
// After specialization, we need to ensure that custom timezone
130+
// settings configured by the user (WEBSITE_TIME_ZONE) are honored.
131+
// DateTime caches timezone information, so we need to clear the cache.
132+
TimeZoneInfo.ClearCachedData();
128133
}
129134

130135
_standbyHostManager?.Dispose();

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public async Task StandbyMode_EndToEnd()
8484
IsSelfHost = true,
8585
LogPath = Path.Combine(testRootPath, "Logs"),
8686
SecretsPath = Path.Combine(testRootPath, "Secrets"),
87+
ScriptPath = testRootPath,
8788
TraceWriter = traceWriter
8889
};
8990

@@ -111,6 +112,12 @@ 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

@@ -121,6 +128,7 @@ public async Task StandbyMode_EndToEnd()
121128
Assert.Equal(2, logLines.Count(p => p.Contains("Host is in standby mode")));
122129
Assert.Equal(1, logLines.Count(p => p.Contains("Stopping Host")));
123130
Assert.Equal(2, logLines.Count(p => p.Contains("Executed 'Functions.WarmUp' (Succeeded")));
131+
Assert.Equal(1, logLines.Count(p => p.Contains("Starting host specialization")));
124132
}
125133
}
126134
}

0 commit comments

Comments
 (0)