Skip to content

Commit

Permalink
When opting to 'Standardize App Pool Recycles', the new recycle times…
Browse files Browse the repository at this point in the history
… will be spaced out by 1 min to prevent a CPU spike at the recycle time. Updated version to 2.1.
  • Loading branch information
kevinsea committed Aug 21, 2016
1 parent 03b59b1 commit a785741
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
16 changes: 12 additions & 4 deletions DesiredStateGenerator/IIS/IISCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,27 @@ public string GenerateIisSiteImports()

private string GeneratePools(IEnumerable<PoolDesiredState> poolList)
{
int poolCounter = 0;
StringBuilder sb = new StringBuilder();
string code = "";

foreach (var poolCode in poolList)
{
code = GeneratePool(poolCode);
code = GeneratePool(poolCode, poolCounter);
sb.AppendLine(code);
poolCounter++;
}

return sb.ToString();
}

private static string GeneratePool(PoolDesiredState poolCode)
private static string GeneratePool(PoolDesiredState poolCode, int poolCounter)
{
return poolCode.GetCode(2);
string code = poolCode.GetCode(2);

string poolMinStr = (poolCounter % 60).ToString("00");
code = code.Replace("#PoolRecycleMins#", poolMinStr + ":00");
return code;
}

private string GenerateSites(List<SiteDesiredState> siteList)
Expand Down Expand Up @@ -111,6 +117,7 @@ private string GenerateSitesAndPools(IEnumerable<SiteDesiredState> siteList
, IEnumerable<PoolDesiredState> poolList)
{
string code = "";
int poolCounter = 0;
StringBuilder sb = new StringBuilder();

List<PoolDesiredState> poolsLeftToGenerate = new List<PoolDesiredState>(poolList);
Expand All @@ -128,7 +135,8 @@ private string GenerateSitesAndPools(IEnumerable<SiteDesiredState> siteList

if (poolToGenerate != null)
{
code = GeneratePool(poolToGenerate);
code = GeneratePool(poolToGenerate, poolCounter);
poolCounter++;
sb.AppendLine(code);

poolsLeftToGenerate.Remove(poolToGenerate);
Expand Down
2 changes: 1 addition & 1 deletion DesiredStateGenerator/IIS/PoolDesiredState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private void Initialize(ApplicationPool iisPoolObject, IISCodeGenerator.IisPoolA

if (iisOptions.StandardizeAppPoolRecycles)
{
string recycleTime = "$appPoolRecycleHour+':00:00'";//.Replace("'", "\"");
string recycleTime = "$appPoolRecycleHour+':#PoolRecycleMins#'"; //tag mins so it can be injected at code gen
this.AddAttributeWithOverrideValue("RestartSchedule", $"@({recycleTime})", GetScheduleString(iisPoolObject));
}
else
Expand Down
4 changes: 2 additions & 2 deletions DesiredStateGenerator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.3")]
[assembly: AssemblyFileVersion("2.0.3")]
[assembly: AssemblyVersion("2.1.0")]
[assembly: AssemblyFileVersion("2.1.0")]

0 comments on commit a785741

Please sign in to comment.