예제 #1
0
파일: Startup.cs 프로젝트: ashbrener/kudu
        private static void SetupKuduServices(IKernel kernel)
        {
            string root                = HttpRuntime.AppDomainAppPath;
            string serviceSitePath     = ConfigurationManager.AppSettings["serviceSitePath"];
            string sitesPath           = ConfigurationManager.AppSettings["sitesPath"];
            string sitesBaseUrl        = ConfigurationManager.AppSettings["urlBaseValue"];
            string serviceSitesBaseUrl = ConfigurationManager.AppSettings["serviceUrlBaseValue"];

            serviceSitePath = Path.Combine(root, serviceSitePath);
            sitesPath       = Path.Combine(root, sitesPath);

            var pathResolver     = new DefaultPathResolver(serviceSitePath, sitesPath);
            var settingsResolver = new DefaultSettingsResolver(sitesBaseUrl, serviceSitesBaseUrl);

            kernel.Bind <IPathResolver>().ToConstant(pathResolver);
            kernel.Bind <ISettingsResolver>().ToConstant(settingsResolver);
            kernel.Bind <ISiteManager>().To <SiteManager>().InSingletonScope();
            kernel.Bind <KuduEnvironment>().ToMethod(_ => new KuduEnvironment
            {
                RunningAgainstLocalKuduService = true,
                IsAdmin         = IdentityHelper.IsAnAdministrator(),
                ServiceSitePath = pathResolver.ServiceSitePath,
                SitesPath       = pathResolver.SitesPath
            });

            // TODO: Integrate with membership system
            kernel.Bind <ICredentialProvider>().ToConstant(new BasicAuthCredentialProvider("admin", "kudu"));
            kernel.Bind <IApplicationService>().To <ApplicationService>().InRequestScope();
            kernel.Bind <ISettingsService>().To <SettingsService>();

            // Sql CE setup
            Directory.CreateDirectory(Path.Combine(root, "App_Data"));
        }
예제 #2
0
        public static ApplicationManager CreateApplication(string applicationName)
        {
            var pathResolver     = new DefaultPathResolver(PathHelper.ServiceSitePath, PathHelper.SitesPath);
            var settingsResolver = new DefaultSettingsResolver();

            var siteManager = GetSiteManager(pathResolver, settingsResolver);

            try
            {
                siteManager.DeleteSite(applicationName);
            }
            catch (Exception)
            {
            }

            Site site = siteManager.CreateSite(applicationName);

            string gitUrl            = null;
            var    repositoryManager = new RemoteRepositoryManager(site.ServiceUrl + "live/scm");
            var    repositoryInfo    = repositoryManager.GetRepositoryInfo().Result;

            gitUrl = repositoryInfo.GitUrl.ToString();
            return(new ApplicationManager(siteManager, site, applicationName, gitUrl, settingsResolver)
            {
                SiteUrl = site.SiteUrl,
                ServiceUrl = site.ServiceUrl,
                DeploymentManager = new RemoteDeploymentManager(site.ServiceUrl + "deployments"),
                ProjectSystem = new RemoteProjectSystem(site.ServiceUrl + "live/files"),
                SettingsManager = new RemoteDeploymentSettingsManager(site.ServiceUrl + "settings"),
                LogStreamManager = new RemoteLogStreamManager(site.ServiceUrl + "logstream"),
                SSHKeyManager = new RemoteSSHKeyManager(site.ServiceUrl + "sshkey"),
                RepositoryManager = repositoryManager
            });
        }
예제 #3
0
파일: SitePool.cs 프로젝트: n3rd/kudu
        private static async Task <ApplicationManager> CreateApplicationInternal()
        {
            int siteIndex;

            _availableSiteIndex.TryPop(out siteIndex);
            string applicationName = _sitePrefix + siteIndex;

            string operationName = "SitePool.CreateApplicationInternal " + applicationName;

            var pathResolver        = new DefaultPathResolver(PathHelper.ServiceSitePath, PathHelper.SitesPath);
            var settingsResolver    = new DefaultSettingsResolver();
            var certificateResolver = new X509Certificate2Resolver();

            var siteManager = GetSiteManager(pathResolver, settingsResolver, certificateResolver);

            Site site = siteManager.GetSite(applicationName);

            if (site != null)
            {
                TestTracer.Trace("{0} Site already exists at {1}. Reusing site", operationName, site.SiteUrl);
                var appManager = new ApplicationManager(siteManager, site, applicationName, settingsResolver)
                {
                    SitePoolIndex = siteIndex
                };

                // In site reuse mode, clean out the existing site so we start clean
                // Enumrate all w3wp processes and make sure to kill any process with an open handle to klr.host.dll
                foreach (var process in (await appManager.ProcessManager.GetProcessesAsync()).Where(p => p.Name.Equals("w3wp", StringComparison.OrdinalIgnoreCase)))
                {
                    var extendedProcess = await appManager.ProcessManager.GetProcessAsync(process.Id);

                    if (extendedProcess.OpenFileHandles.Any(h => h.IndexOf("klr.host.dll", StringComparison.OrdinalIgnoreCase) != -1))
                    {
                        await appManager.ProcessManager.KillProcessAsync(extendedProcess.Id, throwOnError : false);
                    }
                }

                await appManager.RepositoryManager.Delete(deleteWebRoot : true, ignoreErrors : true);

                // Make sure we start with the correct default file as some tests expect it
                WriteIndexHtml(appManager);

                TestTracer.Trace("{0} completed", operationName);
                return(appManager);
            }
            else
            {
                TestTracer.Trace("{0} Creating new site", operationName);
                site = await siteManager.CreateSiteAsync(applicationName);

                TestTracer.Trace("{0} Created new site at {1}", operationName, site.SiteUrl);
                return(new ApplicationManager(siteManager, site, applicationName, settingsResolver)
                {
                    SitePoolIndex = siteIndex
                });
            }
        }
예제 #4
0
        private static async Task <ApplicationManager> CreateApplicationInternal()
        {
            int siteIndex;

            _availableSiteIndex.TryPop(out siteIndex);
            string applicationName = _sitePrefix + siteIndex;

            string operationName = "SitePool.CreateApplicationInternal " + applicationName;

            var pathResolver     = new DefaultPathResolver(PathHelper.ServiceSitePath, PathHelper.SitesPath);
            var settingsResolver = new DefaultSettingsResolver();

            var siteManager = GetSiteManager(pathResolver, settingsResolver);

            Site site = siteManager.GetSite(applicationName);

            if (site != null)
            {
                TestTracer.Trace("{0} Site already exists at {1}. Reusing site", operationName, site.SiteUrl);
                var appManager = new ApplicationManager(siteManager, site, applicationName, settingsResolver)
                {
                    SitePoolIndex = siteIndex
                };

                // In site reuse mode, clean out the existing site so we start clean
                await appManager.RepositoryManager.Delete(deleteWebRoot : true, ignoreErrors : true);

                // Make sure we start with the correct default file as some tests expect it
                WriteIndexHtml(appManager);

                TestTracer.Trace("{0} completed", operationName);
                return(appManager);
            }
            else
            {
                TestTracer.Trace("{0} Creating new site", operationName);
                site = await siteManager.CreateSiteAsync(applicationName);

                TestTracer.Trace("{0} Created new site at {1}", operationName, site.SiteUrl);
                return(new ApplicationManager(siteManager, site, applicationName, settingsResolver)
                {
                    SitePoolIndex = siteIndex
                });
            }
        }
예제 #5
0
파일: Startup.cs 프로젝트: n3rd/kudu
        private static void SetupKuduServices(IKernel kernel)
        {
            string root                 = HttpRuntime.AppDomainAppPath;
            string serviceSitePath      = ConfigurationManager.AppSettings["serviceSitePath"];
            string sitesPath            = ConfigurationManager.AppSettings["sitesPath"];
            string sitesBaseUrl         = ConfigurationManager.AppSettings["urlBaseValue"];
            string serviceSitesBaseUrl  = ConfigurationManager.AppSettings["serviceUrlBaseValue"];
            string customHostNames      = ConfigurationManager.AppSettings["enableCustomHostNames"];
            string serviceSiteBasicAuth = ConfigurationManager.AppSettings["enableServiceSiteBasicAuth"];

            serviceSitePath = Path.Combine(root, serviceSitePath);
            sitesPath       = Path.Combine(root, sitesPath);

            var pathResolver     = new DefaultPathResolver(serviceSitePath, sitesPath);
            var settingsResolver = new DefaultSettingsResolver(sitesBaseUrl, serviceSitesBaseUrl, customHostNames, serviceSiteBasicAuth);

            kernel.Bind <IPathResolver>().ToConstant(pathResolver);
            kernel.Bind <ISettingsResolver>().ToConstant(settingsResolver);
            kernel.Bind <ICertificateResolver>().To <X509Certificate2Resolver>();
            kernel.Bind <ISiteManager>().To <SiteManager>().InSingletonScope();
            kernel.Bind <KuduEnvironment>().ToMethod(_ => new KuduEnvironment
            {
                RunningAgainstLocalKuduService = true,
                IsAdmin         = IdentityHelper.IsAnAdministrator(),
                ServiceSitePath = pathResolver.ServiceSitePath,
                SitesPath       = pathResolver.SitesPath
            });

            // TODO: Integrate with membership system
            kernel.Bind <ICredentialProvider>().To <BasicAuthProxyCredentialProvider>().InRequestScope().WithConstructorArgument("context", _ => new HttpContextWrapper(HttpContext.Current));
            kernel.Bind <IApplicationService>().To <ApplicationService>().InRequestScope();
            kernel.Bind <ISettingsService>().To <SettingsService>();

            // Sql CE setup
            Directory.CreateDirectory(Path.Combine(root, "App_Data"));
        }
예제 #6
0
파일: SitePool.cs 프로젝트: rudimk/kudu
 private static ISiteManager GetSiteManager(DefaultPathResolver pathResolver, DefaultSettingsResolver settingsResolver)
 {
     return(new SiteManager(pathResolver, traceFailedRequests: true, logPath: PathHelper.TestResultsPath, settingsResolver: settingsResolver));
 }
예제 #7
0
        public static ApplicationManager CreateApplication(string applicationName, string testName = null)
        {
            // Default the test name to the app name
            testName = testName ?? applicationName;

            TestTracer.Trace("Create application - {0}", applicationName);

            var pathResolver     = new DefaultPathResolver(PathHelper.ServiceSitePath, PathHelper.SitesPath);
            var settingsResolver = new DefaultSettingsResolver();

            var siteManager = GetSiteManager(pathResolver, settingsResolver);

            Site site;

            if (KuduUtils.ReuseSameSiteForAllTests)
            {
                // In site reuse mode, try to get the existing site, and create it if needed
                site = siteManager.GetSite(applicationName);
                if (site == null)
                {
                    site = siteManager.CreateSite(applicationName);
                }
            }
            else
            {
                try
                {
                    siteManager.DeleteSite(applicationName);
                }
                catch (Exception)
                {
                }

                site = siteManager.CreateSite(applicationName);
            }

            TestTracer.Trace("Using site - {0}", site.SiteUrl);

            string gitUrl            = null;
            var    repositoryManager = new RemoteRepositoryManager(site.ServiceUrl + "scm");
            var    repositoryInfo    = repositoryManager.GetRepositoryInfo().Result;

            gitUrl = repositoryInfo.GitUrl.ToString();
            var applicationManager = new ApplicationManager(siteManager, site, applicationName, gitUrl, settingsResolver)
            {
                SiteUrl           = site.SiteUrl,
                ServiceUrl        = site.ServiceUrl,
                DeploymentManager = new RemoteDeploymentManager(site.ServiceUrl + "deployments"),
                SettingsManager   = new RemoteDeploymentSettingsManager(site.ServiceUrl + "settings"),
                LogStreamManager  = new RemoteLogStreamManager(site.ServiceUrl + "logstream"),
                SSHKeyManager     = new RemoteSSHKeyManager(site.ServiceUrl + "sshkey"),
                VfsManager        = new RemoteVfsManager(site.ServiceUrl + "vfs"),
                VfsWebRootManager = new RemoteVfsManager(site.ServiceUrl + "vfs/site/wwwroot"),
                LiveScmVfsManager = new RemoteVfsManager(site.ServiceUrl + "scmvfs"),
                ZipManager        = new RemoteZipManager(site.ServiceUrl + "zip"),
                CommandExecutor   = new RemoteCommandExecutor(site.ServiceUrl + "command"),
                RepositoryManager = repositoryManager,
            };

            return(applicationManager);
        }