Skip to content

Commit

Permalink
stop before dispose a scriptHostManager
Browse files Browse the repository at this point in the history
  • Loading branch information
watashiSHUN committed Nov 8, 2017
1 parent a2c2693 commit ae05f55
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/WebJobs.Script.WebHost/App_Start/WebHostResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ internal void EnsureInitialized(WebHostSettings settings)
TimeZoneInfo.ClearCachedData();
}

_standbyHostManager?.Dispose();
if (_standbyHostManager != null)
{
_standbyHostManager.Stop();
_standbyHostManager.Dispose();
}
_standbyReceiverManager?.Dispose();
_standbyScriptHostConfig = null;
_standbyHostManager = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public async Task PurgeOldSecretsAsync(IList<string> currentFunctions, TraceWrit
{
try
{
// destructive operation, thus log
string removeSecretsMessage = $"Deleting secret file {secretFile.FullName}";
traceWriter.Verbose(removeSecretsMessage);
logger?.LogDebug(removeSecretsMessage);
await FileUtility.DeleteIfExistsAsync(secretFile.FullName);
}
catch
Expand Down
4 changes: 4 additions & 0 deletions src/WebJobs.Script/Host/ScriptHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@ private void PurgeOldLogDirectories()
// so delete it
try
{
// destructive operation, thus log
string removeLogMessage = $"Deleting log directory '{logDir.FullName}'";
TraceWriter.Verbose(removeLogMessage);
_startupLogger?.LogDebug(removeLogMessage);
logDir.Delete(recursive: true);
}
catch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public async Task StandbyMode_EndToEnd()
// verify logs
string[] logLines = traceWriter.Traces.Select(p => p.Message).ToArray();
Assert.Equal(2, logLines.Count(p => p.Contains("Host is in standby mode")));
Assert.Equal(1, logLines.Count(p => p.Contains("Stopping Host")));
Assert.Equal(2, logLines.Count(p => p.Contains("Stopping Host")));
Assert.Equal(2, logLines.Count(p => p.Contains("Executed 'Functions.WarmUp' (Succeeded")));
Assert.Equal(1, logLines.Count(p => p.Contains("Starting host specialization")));

Expand Down

0 comments on commit ae05f55

Please sign in to comment.