Ejemplo n.º 1
0
        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = 12;
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                string configuration = RoleEnvironment.IsAvailable ?
                    RoleEnvironment.GetConfigurationSettingValue(configName) :
                    ConfigurationManager.AppSettings[configName];

                configSetter(configuration);
            });

            ConfigureDiagnosticMonitor();

            Trace.TraceInformation("WebRole.OnStart");

            // Initialize local resources
            var localSitesPath = GetLocalResourcePathAndSetAccess("Sites");
            var localTempPath = GetLocalResourcePathAndSetAccess("TempSites");

            // Get settings
            var directoriesToExclude = RoleEnvironment.GetConfigurationSettingValue("DirectoriesToExclude").Split(';');

            // WebDeploy creates temporary files during package creation. The default TEMP location allows for a 100MB
            // quota (see http://msdn.microsoft.com/en-us/library/gg465400.aspx#Y976).
            // For large web deploy packages, the synchronization process will raise an IO exception because the "disk is full"
            // unless you ensure that the TEMP/TMP target directory has sufficient space
            Environment.SetEnvironmentVariable("TMP", localTempPath);
            Environment.SetEnvironmentVariable("TEMP", localTempPath);

            // Populate the certificate repository.
            var certRepo = new CertificateRepository();
            certRepo.PopulateRepository();

            // Create the sync service and update the sites status
            this.syncService = new SyncService(localSitesPath, localTempPath, directoriesToExclude, "DataConnectionstring");
            this.syncService.Start();

            return base.OnStart();
        }