public InfoRefsService(ITracer tracer, IGitServer gitServer, IEnvironment environment, RepositoryConfiguration configuration) { _gitServer = gitServer; _tracer = tracer; _deploymentTargetPath = environment.DeploymentTargetPath; _configuration = configuration; }
public FetchHandler(ITracer tracer, IGitServer gitServer, IDeploymentManager deploymentManager, IOperationLock deploymentLock, RepositoryConfiguration configuration) { _gitServer = gitServer; _deploymentManager = deploymentManager; _tracer = tracer; _deploymentLock = deploymentLock; _configuration = configuration; }
public LiveScmEditorController(ITracer tracer, IOperationLock operationLock, IEnvironment environment, IRepository repository, RepositoryConfiguration configuration) : base(tracer, environment, environment.RepositoryPath) { _operationLock = operationLock; _repository = repository; _repositoryConfiguration = configuration; _currentEtag = GetCurrentEtag(); }
public FetchHandler(ITracer tracer, IGitServer gitServer, IDeploymentManager deploymentManager, IDeploymentSettingsManager settings, IOperationLock deploymentLock, RepositoryConfiguration configuration, IEnvironment environment) : base(tracer, gitServer, deploymentLock, deploymentManager) { _settings = settings; _configuration = configuration; _environment = environment; }
public InfoRefsController( ITracer tracer, IGitServer gitServer, IDeploymentManager deploymentManager, IEnvironment environment, RepositoryConfiguration configuration) { _gitServer = gitServer; _deploymentManager = deploymentManager; _tracer = tracer; _webRootPath = environment.WebRootPath; _configuration = configuration; }
private void InitializeRepository(RepositoryConfiguration configuration) { ITracer tracer = _traceFactory.GetTracer(); using (tracer.Step("GitExeServer.Initialize")) { _repository.Initialize(); using (tracer.Step("Configure git server")) { // Allow getting pushes even though we're not bare _gitExe.Execute(tracer, "config receive.denyCurrentBranch ignore"); } using (tracer.Step("Configure git user and email")) { _gitExe.Execute(tracer, @"config user.name ""{0}""", configuration.Username); _gitExe.Execute(tracer, @"config user.email ""{0}""", configuration.Email); } using (tracer.Step("Setup post receive hook")) { FileSystemHelpers.EnsureDirectory(Path.GetDirectoryName(PostReceiveHookPath)); string content = @"#!/bin/sh read i echo $i > pushinfo " + KnownEnviornment.KUDUCOMMAND + "\n"; File.WriteAllText(PostReceiveHookPath, content); } } }
public bool Initialize(RepositoryConfiguration configuration) { if (Exists && !_initLock.IsHeld) { // Repository already exists and there's nothing happening then do nothing return false; } _initLock.LockOrWait(() => InitializeRepository(configuration), _initTimeout); return true; }
public ChangeSet Initialize(RepositoryConfiguration configuration, string path) { if (Exists && !_initLock.IsHeld) { // Repository already exists and there's nothing happening then do nothing return null; } ChangeSet changeSet = null; _initLock.LockOrWait(() => { InitializeRepository(configuration); ITracer tracer = _traceFactory.GetTracer(); using (tracer.Step("GitExeServer.Initialize(path)")) { tracer.Trace("Initializing repository from path", new Dictionary<string, string> { { "path", path } }); using (tracer.Step("Copying files into repository")) { // Copy all of the files into the repository FileSystemHelpers.Copy(path, _gitExe.WorkingDirectory); } // Make the initial commit changeSet = _repository.Commit("Initial commit"); } }, _initTimeout); return changeSet; }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { var serverConfiguration = new ServerConfiguration(); var gitConfiguration = new RepositoryConfiguration { Username = AppSettings.GitUsername, Email = AppSettings.GitEmail, TraceLevel = AppSettings.TraceLevel }; IEnvironment environment = GetEnvironment(); // General kernel.Bind<HttpContextBase>().ToMethod(context => new HttpContextWrapper(HttpContext.Current)); kernel.Bind<IEnvironment>().ToConstant(environment); kernel.Bind<IServerConfiguration>().ToConstant(serverConfiguration); kernel.Bind<IFileSystem>().To<FileSystem>().InSingletonScope(); kernel.Bind<RepositoryConfiguration>().ToConstant(gitConfiguration); string sdkPath = Path.Combine(HttpRuntime.AppDomainAppPath, SdkRootDirectory); kernel.Bind<IBuildPropertyProvider>().ToConstant(new BuildPropertyProvider()); if (AppSettings.TraceEnabled) { string tracePath = Path.Combine(environment.RootPath, Constants.TracePath, Constants.TraceFile); System.Func<ITracer> createTracerThunk = () => new Tracer(tracePath); // First try to use the current request profiler if any, otherwise create a new one var traceFactory = new TracerFactory(() => TraceServices.CurrentRequestTracer ?? createTracerThunk()); kernel.Bind<ITracer>().ToMethod(context => TraceServices.CurrentRequestTracer ?? NullTracer.Instance); kernel.Bind<ITraceFactory>().ToConstant(traceFactory); TraceServices.SetTraceFactory(createTracerThunk); } else { // Return No-op providers kernel.Bind<ITracer>().ToConstant(NullTracer.Instance).InSingletonScope(); kernel.Bind<ITraceFactory>().ToConstant(NullTracerFactory.Instance).InSingletonScope(); } // Setup the deployment lock string lockPath = Path.Combine(environment.SiteRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); string sshKeyLockPath = Path.Combine(lockPath, Constants.SSHKeyLockFile); string initLockPath = Path.Combine(lockPath, Constants.InitLockFile); var deploymentLock = new LockFile(kernel.Get<ITraceFactory>(), deploymentLockPath); var initLock = new LockFile(kernel.Get<ITraceFactory>(), initLockPath); var sshKeyLock = new LockFile(kernel.Get<ITraceFactory>(), sshKeyLockPath); kernel.Bind<IOperationLock>().ToConstant(sshKeyLock).WhenInjectedInto<SSHKeyController>(); kernel.Bind<IOperationLock>().ToConstant(deploymentLock); // Setup the diagnostics service to collect information from the following paths: // 1. The deployments folder // 2. The profile dump // 3. The npm log var paths = new[] { environment.DeploymentCachePath, Path.Combine(environment.RootPath, Constants.LogFilesPath), Path.Combine(environment.WebRootPath, Constants.NpmDebugLogFile), }; kernel.Bind<DiagnosticsController>().ToMethod(context => new DiagnosticsController(paths)); // LogStream service kernel.Bind<LogStreamManager>().ToMethod(context => new LogStreamManager(Path.Combine(environment.RootPath, Constants.LogFilesPath), context.Kernel.Get<ITracer>())); // Deployment Service kernel.Bind<ISettings>().ToMethod(context => new XmlSettings.Settings(GetSettingsPath(environment))); kernel.Bind<IDeploymentSettingsManager>().To<DeploymentSettingsManager>(); kernel.Bind<ISiteBuilderFactory>().To<SiteBuilderFactory>() .InRequestScope(); kernel.Bind<IServerRepository>().ToMethod(context => new GitExeServer(environment.RepositoryPath, initLock, context.Kernel.Get<IDeploymentEnvironment>(), context.Kernel.Get<ITraceFactory>())) .InRequestScope(); kernel.Bind<ILogger>().ToConstant(NullLogger.Instance); kernel.Bind<IDeploymentManager>().To<DeploymentManager>() .InRequestScope(); kernel.Bind<ISSHKeyManager>().To<SSHKeyManager>() .InRequestScope(); kernel.Bind<IDeploymentRepository>().ToMethod(context => new GitDeploymentRepository(environment.RepositoryPath, context.Kernel.Get<ITraceFactory>())) .InRequestScope(); // Git server kernel.Bind<IDeploymentEnvironment>().To<DeploymentEnvrionment>(); kernel.Bind<IGitServer>().ToMethod(context => new GitExeServer(environment.RepositoryPath, initLock, context.Kernel.Get<IDeploymentEnvironment>(), context.Kernel.Get<ITraceFactory>())) .InRequestScope(); // Editor kernel.Bind<IProjectSystem>().ToMethod(context => GetEditorProjectSystem(environment, context)) .InRequestScope(); // Command executor kernel.Bind<ICommandExecutor>().ToMethod(context => GetCommandExecutor(environment, context)) .InRequestScope(); RegisterRoutes(kernel, RouteTable.Routes); }
public void Initialize(RepositoryConfiguration configuration) { var profiler = _tracerFactory.GetTracer(); using (profiler.Step("GitExeRepository.Initialize")) { _gitExe.Execute(profiler, "init"); _gitExe.Execute(profiler, "config core.autocrlf true"); _gitExe.Execute(profiler, @"config user.name ""{0}""", configuration.Username); _gitExe.Execute(profiler, @"config user.email ""{0}""", configuration.Email); } }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { var serverConfiguration = new ServerConfiguration(); var gitConfiguration = new RepositoryConfiguration { Username = AppSettings.GitUsername, Email = AppSettings.GitEmail }; IEnvironment environment = GetEnvironment(); var propertyProvider = new BuildPropertyProvider(); // General kernel.Bind<HttpContextBase>().ToMethod(context => new HttpContextWrapper(HttpContext.Current)); kernel.Bind<IBuildPropertyProvider>().ToConstant(propertyProvider); kernel.Bind<IEnvironment>().ToConstant(environment); kernel.Bind<IUserValidator>().To<SimpleUserValidator>().InSingletonScope(); kernel.Bind<IServerConfiguration>().ToConstant(serverConfiguration); kernel.Bind<IFileSystem>().To<FileSystem>().InSingletonScope(); kernel.Bind<RepositoryConfiguration>().ToConstant(gitConfiguration); if (AppSettings.TraceEnabled) { string tracePath = Path.Combine(environment.ApplicationRootPath, TracePath, TraceFile); System.Func<ITracer> createTracerThunk = () => new Tracer(tracePath); // First try to use the current request profiler if any, otherwise create a new one var traceFactory = new TracerFactory(() => TraceServices.CurrentRequestTracer ?? createTracerThunk()); kernel.Bind<ITracer>().ToMethod(context => TraceServices.CurrentRequestTracer ?? NullTracer.Instance); kernel.Bind<ITraceFactory>().ToConstant(traceFactory); TraceServices.SetTraceFactory(createTracerThunk); } else { // Return No-op providers kernel.Bind<ITracer>().ToConstant(NullTracer.Instance).InSingletonScope(); kernel.Bind<ITraceFactory>().ToConstant(NullTracerFactory.Instance).InSingletonScope(); } // Setup the deployment lock string lockPath = Path.Combine(environment.ApplicationRootPath, LockPath); string deploymentLockPath = Path.Combine(lockPath, DeploymentLockFile); string initLockPath = Path.Combine(lockPath, InitLockFile); var deploymentLock = new LockFile(kernel.Get<ITraceFactory>(), deploymentLockPath); var initLock = new LockFile(kernel.Get<ITraceFactory>(), initLockPath); kernel.Bind<IOperationLock>().ToConstant(deploymentLock); // Setup the diagnostics service to collect information from the following paths: // 1. The deployments folder // 2. The elmah error log // 3. The profile dump var paths = new[] { environment.DeploymentCachePath, Path.Combine(environment.ApplicationRootPath, TracePath), }; kernel.Bind<DiagnosticsService>().ToMethod(context => new DiagnosticsService(paths)); // Deployment Service kernel.Bind<ISettings>().ToMethod(context => new XmlSettings.Settings(GetSettingsPath(environment))); kernel.Bind<IDeploymentSettingsManager>().To<DeploymentSettingsManager>(); kernel.Bind<ISiteBuilderFactory>().To<SiteBuilderFactory>() .InRequestScope(); kernel.Bind<IServerRepository>().ToMethod(context => new GitExeServer(environment.DeploymentRepositoryPath, initLock, context.Kernel.Get<ITraceFactory>())) .InRequestScope(); kernel.Bind<IDeploymentManager>().To<DeploymentManager>() .InRequestScope() .OnActivation(SubscribeForDeploymentEvents); // Git server kernel.Bind<IDeploymentManagerFactory>().ToMethod(context => GetDeploymentManagerFactory(environment, initLock, deploymentLock, propertyProvider, context.Kernel.Get<ITraceFactory>())); kernel.Bind<IGitServer>().ToMethod(context => new GitExeServer(environment.DeploymentRepositoryPath, initLock, context.Kernel.Get<ITraceFactory>())) .InRequestScope(); // Hg Server kernel.Bind<IHgServer>().To<Kudu.Core.SourceControl.Hg.HgServer>() .InSingletonScope(); // Editor kernel.Bind<IProjectSystem>().ToMethod(context => GetEditorProjectSystem(environment, context)) .InRequestScope(); // Command line //kernel.Bind<ICommandExecutor>().ToMethod(context => GetComandExecutor(environment, context)) // .InRequestScope(); // Source control // kernel.Bind<IRepository>().ToMethod(context => GetSourceControlRepository(environment)); //kernel.Bind<IClonableRepository>().ToMethod(context => (IClonableRepository)GetDevelopmentRepositoryManager(environment)); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { var serverConfiguration = new ServerConfiguration(); var gitConfiguration = new RepositoryConfiguration { Username = AppSettings.GitUsername, Email = AppSettings.GitEmail }; IEnvironment environment = GetEnvironment(); // General kernel.Bind<HttpContextBase>().ToMethod(context => new HttpContextWrapper(HttpContext.Current)); kernel.Bind<IEnvironment>().ToConstant(environment); kernel.Bind<IServerConfiguration>().ToConstant(serverConfiguration); kernel.Bind<IFileSystem>().To<FileSystem>().InSingletonScope(); kernel.Bind<RepositoryConfiguration>().ToConstant(gitConfiguration); string sdkPath = Path.Combine(HttpRuntime.AppDomainAppPath, SdkRootDirectory); kernel.Bind<IBuildPropertyProvider>().ToConstant(new BuildPropertyProvider()); System.Func<ITracer> createTracerThunk = () => GetTracer(environment, kernel); System.Func<ILogger> createLoggerThunk = () => GetLogger(environment, kernel); // First try to use the current request profiler if any, otherwise create a new one var traceFactory = new TracerFactory(() => TraceServices.CurrentRequestTracer ?? createTracerThunk()); kernel.Bind<ITracer>().ToMethod(context => TraceServices.CurrentRequestTracer ?? NullTracer.Instance); kernel.Bind<ITraceFactory>().ToConstant(traceFactory); TraceServices.SetTraceFactory(createTracerThunk, createLoggerThunk); // Setup the deployment lock string lockPath = Path.Combine(environment.SiteRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); string sshKeyLockPath = Path.Combine(lockPath, Constants.SSHKeyLockFile); string initLockPath = Path.Combine(lockPath, Constants.InitLockFile); var deploymentLock = new LockFile(kernel.Get<ITraceFactory>(), deploymentLockPath); var initLock = new LockFile(kernel.Get<ITraceFactory>(), initLockPath); var sshKeyLock = new LockFile(kernel.Get<ITraceFactory>(), sshKeyLockPath); kernel.Bind<IOperationLock>().ToConstant(sshKeyLock).WhenInjectedInto<SSHKeyController>(); kernel.Bind<IOperationLock>().ToConstant(deploymentLock); var shutdownDetector = new ShutdownDetector(); shutdownDetector.Initialize(); // LogStream service kernel.Bind<LogStreamManager>().ToMethod(context => new LogStreamManager(Path.Combine(environment.RootPath, Constants.LogFilesPath), context.Kernel.Get<ITracer>(), shutdownDetector)); // Deployment Service kernel.Bind<ISettings>().ToMethod(context => new XmlSettings.Settings(GetSettingsPath(environment))) .InRequestScope(); kernel.Bind<IDeploymentSettingsManager>().To<DeploymentSettingsManager>() .InRequestScope(); kernel.Bind<ISiteBuilderFactory>().To<SiteBuilderFactoryDispatcher>() .InRequestScope(); kernel.Bind<IServerRepository>().ToMethod(context => new GitExeServer(environment.RepositoryPath, environment.SiteRootPath, initLock, GetRequestTraceFile(environment, context.Kernel), context.Kernel.Get<IDeploymentEnvironment>(), context.Kernel.Get<ITraceFactory>())) .InRequestScope(); kernel.Bind<ILogger>().ToMethod(context => GetLogger(environment, context.Kernel)) .InRequestScope(); kernel.Bind<IRepository>().ToMethod(context => new GitExeRepository(environment.RepositoryPath, environment.SiteRootPath, context.Kernel.Get<ITraceFactory>())) .InRequestScope(); kernel.Bind<IDeploymentManager>().To<DeploymentManager>() .InRequestScope(); kernel.Bind<ISSHKeyManager>().To<SSHKeyManager>() .InRequestScope(); kernel.Bind<IDeploymentRepository>().ToMethod(context => new GitDeploymentRepository(environment.RepositoryPath, environment.SiteRootPath, context.Kernel.Get<ITraceFactory>())) .InRequestScope(); // Git server kernel.Bind<IDeploymentEnvironment>().To<DeploymentEnvrionment>(); kernel.Bind<IGitServer>().ToMethod(context => new GitExeServer(environment.RepositoryPath, environment.SiteRootPath, initLock, GetRequestTraceFile(environment, context.Kernel), context.Kernel.Get<IDeploymentEnvironment>(), context.Kernel.Get<ITraceFactory>())) .InRequestScope(); // Git Servicehook parsers kernel.Bind<IServiceHookHandler>().To<GitHubHandler>().InRequestScope(); kernel.Bind<IServiceHookHandler>().To<BitbucketHandler>().InRequestScope(); kernel.Bind<IServiceHookHandler>().To<DropboxHandler>().InRequestScope(); kernel.Bind<IServiceHookHandler>().To<CodePlexHandler>().InRequestScope(); kernel.Bind<IServiceHookHandler>().To<CodebaseHqHandler>().InRequestScope(); kernel.Bind<IServiceHookHandler>().To<GitlabHqHandler>().InRequestScope(); kernel.Bind<IServiceHookHandler>().To<GitHubCompatHandler>().InRequestScope(); // Command executor kernel.Bind<ICommandExecutor>().ToMethod(context => GetCommandExecutor(environment, context)) .InRequestScope(); RegisterRoutes(kernel, RouteTable.Routes); }