11using System ;
2+ using System . ComponentModel . Design ;
3+ using System . Net . Configuration ;
24using System . Threading ;
35using AzureWebFarm . OctopusDeploy . Infrastructure ;
46using Microsoft . WindowsAzure . ServiceRuntime ;
@@ -12,12 +14,14 @@ namespace AzureWebFarm.OctopusDeploy
1214 public class WebFarmRole
1315 {
1416 private readonly Infrastructure . OctopusDeploy _octopusDeploy ;
17+ private readonly bool _purgesites ;
1518
1619 /// <summary>
1720 /// Create the web role coordinator.
1821 /// </summary>
1922 /// <param name="machineName">Specify the machineName if you would like to override the default machine name configuration.</param>
20- public WebFarmRole ( string machineName = null )
23+ /// <param name="purgeSites">Specify true to remove all sites before installing the tentacle</param>
24+ public WebFarmRole ( string machineName = null , bool purgeSites = false )
2125 {
2226 Log . Logger = AzureEnvironment . GetAzureLogger ( ) ;
2327 var config = AzureEnvironment . GetConfigSettings ( ) ;
@@ -26,7 +30,9 @@ public WebFarmRole(string machineName = null)
2630 var octopusRepository = Infrastructure . OctopusDeploy . GetRepository ( config ) ;
2731 var processRunner = new ProcessRunner ( ) ;
2832 var registryEditor = new RegistryEditor ( ) ;
33+
2934 _octopusDeploy = new Infrastructure . OctopusDeploy ( machineName , config , octopusRepository , processRunner , registryEditor ) ;
35+ _purgesites = purgeSites ;
3036
3137 AzureEnvironment . RequestRecycleIfConfigSettingChanged ( config ) ;
3238 }
@@ -37,8 +43,14 @@ public WebFarmRole(string machineName = null)
3743 /// <returns>true; throws exception is there is an error</returns>
3844 public bool OnStart ( )
3945 {
46+ if ( _purgesites )
47+ {
48+ IisEnvironment . PurgeAllSites ( ) ;
49+ }
50+
4051 _octopusDeploy . ConfigureTentacle ( ) ;
4152 _octopusDeploy . DeployAllCurrentReleasesToThisMachine ( ) ;
53+
4254 return true ;
4355 }
4456
0 commit comments