static int Main(string[] args) { // Turn flag on in app.config to wait for debugger on launch if (ConfigurationManager.AppSettings["WaitForDebuggerOnStart"] == "true") { while (!Debugger.IsAttached) { System.Threading.Thread.Sleep(100); } } if (args.Length < 2) { System.Console.WriteLine("Usage: kudu.exe appRoot wapTargets [deployer]"); return 1; } // The post receive hook launches the exe from sh and intereprets newline differently. // This fixes very wacky issues with how the output shows up in the conosle on push System.Console.Error.NewLine = "\n"; System.Console.Out.NewLine = "\n"; System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); string appRoot = args[0]; string wapTargets = args[1]; string deployer = args.Length == 2 ? null : args[2]; IEnvironment env = GetEnvironment(appRoot); ISettings settings = new XmlSettings.Settings(GetSettingsPath(env)); IDeploymentSettingsManager settingsManager = new DeploymentSettingsManager(settings); // Adjust repo path env.RepositoryPath = Path.Combine(env.SiteRootPath, settingsManager.GetRepositoryPath()); // Setup the trace IFileSystem fileSystem = new FileSystem(); TraceLevel level = settingsManager.GetTraceLevel(); ITracer tracer = GetTracer(env, level, fileSystem); ITraceFactory traceFactory = new TracerFactory(() => tracer); // Calculate the lock path string lockPath = Path.Combine(env.SiteRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); string statusLockPath = Path.Combine(lockPath, Constants.StatusLockFile); IOperationLock deploymentLock = new LockFile(deploymentLockPath, traceFactory, fileSystem); IOperationLock statusLock = new LockFile(statusLockPath, traceFactory, fileSystem); IBuildPropertyProvider buildPropertyProvider = new BuildPropertyProvider(); ISiteBuilderFactory builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); IRepository gitRepository = new GitExeRepository(env, settingsManager, traceFactory); var logger = new ConsoleLogger(); IDeploymentManager deploymentManager = new DeploymentManager(builderFactory, env, fileSystem, traceFactory, settingsManager, new DeploymentStatusManager(env, fileSystem, statusLock), deploymentLock, GetLogger(env, level, logger)); var step = tracer.Step("Executing external process", new Dictionary<string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.Deploy(gitRepository, changeSet: null, deployer: deployer, clean: false); } catch (Exception e) { System.Console.Error.WriteLine(e.Message); System.Console.Error.WriteLine(Resources.Log_DeploymentError); return 1; } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return 1; } return 0; }
private static int PerformDeploy( string appRoot, string wapTargets, string deployer, string lockPath, IEnvironment env, IDeploymentSettingsManager settingsManager, TraceLevel level, ITracer tracer, ITraceFactory traceFactory, IOperationLock deploymentLock) { System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); // Skip SSL Certificate Validate OperationClient.SkipSslValidationIfNeeded(); // Adjust repo path env.RepositoryPath = Path.Combine(env.SiteRootPath, settingsManager.GetRepositoryPath()); string statusLockPath = Path.Combine(lockPath, Constants.StatusLockFile); string hooksLockPath = Path.Combine(lockPath, Constants.HooksLockFile); IOperationLock statusLock = new LockFile(statusLockPath, traceFactory); IOperationLock hooksLock = new LockFile(hooksLockPath, traceFactory); IBuildPropertyProvider buildPropertyProvider = new BuildPropertyProvider(); ISiteBuilderFactory builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); var logger = new ConsoleLogger(); IRepository gitRepository; if (settingsManager.UseLibGit2SharpRepository()) { gitRepository = new LibGit2SharpRepository(env, settingsManager, traceFactory); } else { gitRepository = new GitExeRepository(env, settingsManager, traceFactory); } IServerConfiguration serverConfiguration = new ServerConfiguration(); IAnalytics analytics = new Analytics(settingsManager, serverConfiguration, traceFactory); IWebHooksManager hooksManager = new WebHooksManager(tracer, env, hooksLock); IDeploymentStatusManager deploymentStatusManager = new DeploymentStatusManager(env, analytics, statusLock); IAutoSwapHandler autoSwapHander = new AutoSwapHandler(env, settingsManager, traceFactory); var functionManager = new FunctionManager(env, traceFactory); IDeploymentManager deploymentManager = new DeploymentManager(builderFactory, env, traceFactory, analytics, settingsManager, deploymentStatusManager, deploymentLock, GetLogger(env, level, logger), hooksManager, functionManager); var step = tracer.Step(XmlTracer.ExecutingExternalProcessTrace, new Dictionary<string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.DeployAsync(gitRepository, changeSet: null, deployer: deployer, clean: false) .Wait(); string branch = settingsManager.GetBranch(); ChangeSet changeSet = gitRepository.GetChangeSet(branch); IDeploymentStatusFile statusFile = deploymentStatusManager.Open(changeSet.Id); if (statusFile != null && statusFile.Status == DeployStatus.Success) { autoSwapHander.HandleAutoSwap(changeSet.Id, deploymentManager.GetLogger(changeSet.Id), tracer).Wait(); } } catch (Exception e) { tracer.TraceError(e); System.Console.Error.WriteLine(e.GetBaseException().Message); System.Console.Error.WriteLine(Resources.Log_DeploymentError); return 1; } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return 1; } return 0; }
private static int Main(string[] args) { // Turn flag on in app.config to wait for debugger on launch if (ConfigurationManager.AppSettings["WaitForDebuggerOnStart"] == "true") { while (!Debugger.IsAttached) { System.Threading.Thread.Sleep(100); } } if (System.Environment.GetEnvironmentVariable(SettingsKeys.DisableDeploymentOnPush) == "1") { return(0); } if (args.Length < 2) { System.Console.WriteLine("Usage: kudu.exe appRoot wapTargets [deployer]"); return(1); } // The post receive hook launches the exe from sh and intereprets newline differently. // This fixes very wacky issues with how the output shows up in the console on push System.Console.Error.NewLine = "\n"; System.Console.Out.NewLine = "\n"; System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); // Skip SSL Certificate Validate OperationClient.SkipSslValidationIfNeeded(); string appRoot = args[0]; string wapTargets = args[1]; string deployer = args.Length == 2 ? null : args[2]; IEnvironment env = GetEnvironment(appRoot); ISettings settings = new XmlSettings.Settings(GetSettingsPath(env)); IDeploymentSettingsManager settingsManager = new DeploymentSettingsManager(settings); // Adjust repo path env.RepositoryPath = Path.Combine(env.SiteRootPath, settingsManager.GetRepositoryPath()); // Setup the trace TraceLevel level = settingsManager.GetTraceLevel(); ITracer tracer = GetTracer(env, level); ITraceFactory traceFactory = new TracerFactory(() => tracer); // Calculate the lock path string lockPath = Path.Combine(env.SiteRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); string statusLockPath = Path.Combine(lockPath, Constants.StatusLockFile); string hooksLockPath = Path.Combine(lockPath, Constants.HooksLockFile); IOperationLock deploymentLock = new LockFile(deploymentLockPath, traceFactory); IOperationLock statusLock = new LockFile(statusLockPath, traceFactory); IOperationLock hooksLock = new LockFile(hooksLockPath, traceFactory); IBuildPropertyProvider buildPropertyProvider = new BuildPropertyProvider(); ISiteBuilderFactory builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); IRepository gitRepository; if (settingsManager.UseLibGit2SharpRepository()) { gitRepository = new LibGit2SharpRepository(env, settingsManager, traceFactory); } else { gitRepository = new GitExeRepository(env, settingsManager, traceFactory); } IServerConfiguration serverConfiguration = new ServerConfiguration(); IAnalytics analytics = new Analytics(settingsManager, serverConfiguration, traceFactory); IWebHooksManager hooksManager = new WebHooksManager(tracer, env, hooksLock); IDeploymentStatusManager deploymentStatusManager = new DeploymentStatusManager(env, analytics, statusLock); IAutoSwapHandler autoSwapHander = new AutoSwapHandler(deploymentStatusManager, env, settingsManager, traceFactory); var functionManager = new FunctionManager(env, traceFactory); var logger = new ConsoleLogger(); IDeploymentManager deploymentManager = new DeploymentManager(builderFactory, env, traceFactory, analytics, settingsManager, deploymentStatusManager, deploymentLock, GetLogger(env, level, logger), hooksManager, autoSwapHander, functionManager); var step = tracer.Step(XmlTracer.ExecutingExternalProcessTrace, new Dictionary <string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.DeployAsync(gitRepository, changeSet: null, deployer: deployer, clean: false) .Wait(); } catch (Exception e) { tracer.TraceError(e); System.Console.Error.WriteLine(e.GetBaseException().Message); System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } return(0); }
static int Main(string[] args) { if (args.Length < 2) { System.Console.WriteLine("Usage: kudu.exe {appRoot} {wapTargets}"); return 1; } // The post receive hook launches the exe from sh and intereprets newline differently. // This fixes very wacky issues with how the output shows up in the conosle on push System.Console.Error.NewLine = "\n"; System.Console.Out.NewLine = "\n"; System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); var appRoot = args[0]; var wapTargets = args[1]; string nugetCachePath = null; IEnvironment env = GetEnvironment(appRoot, nugetCachePath); // Setup the trace string tracePath = Path.Combine(env.ApplicationRootPath, Constants.TracePath, Constants.TraceFile); var tracer = new Tracer(tracePath); var traceFactory = new TracerFactory(() => tracer); // Calculate the lock path string lockPath = Path.Combine(env.ApplicationRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); var deploymentLock = new LockFile(traceFactory, deploymentLockPath); var fs = new FileSystem(); var buildPropertyProvider = new BuildPropertyProvider(wapTargets); var builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); var serverRepository = new GitDeploymentRepository(env.DeploymentRepositoryPath, traceFactory); var logger = new ConsoleLogger(); var deploymentManager = new DeploymentManager(serverRepository, builderFactory, env, fs, traceFactory, deploymentLock, logger); var step = tracer.Step("Executing external process", new Dictionary<string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.Deploy(); } catch (System.Exception ex) { System.Console.Error.WriteLine(ex.Message); System.Console.Error.WriteLine(Resources.Log_DeploymentError); tracer.TraceError(ex); throw; } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return 1; } return 0; }
static int Main(string[] args) { if (args.Length < 2) { System.Console.WriteLine("Usage: kudu.exe appRoot wapTargets [deployer]"); return(1); } // The post receive hook launches the exe from sh and intereprets newline differently. // This fixes very wacky issues with how the output shows up in the conosle on push System.Console.Error.NewLine = "\n"; System.Console.Out.NewLine = "\n"; System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); var appRoot = args[0]; var wapTargets = args[1]; string deployer = args.Length == 2 ? null : args[2]; string nugetCachePath = null; IEnvironment env = GetEnvironment(appRoot, nugetCachePath); // Setup the trace string tracePath = Path.Combine(env.ApplicationRootPath, Constants.TracePath, Constants.TraceFile); var tracer = new Tracer(tracePath); var traceFactory = new TracerFactory(() => tracer); // Calculate the lock path string lockPath = Path.Combine(env.ApplicationRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); var deploymentLock = new LockFile(traceFactory, deploymentLockPath); var fs = new FileSystem(); var buildPropertyProvider = new BuildPropertyProvider(wapTargets); var builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); var serverRepository = new GitDeploymentRepository(env.DeploymentRepositoryPath, traceFactory); var logger = new ConsoleLogger(); var deploymentManager = new DeploymentManager(serverRepository, builderFactory, env, fs, traceFactory, deploymentLock, logger); var step = tracer.Step("Executing external process", new Dictionary <string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.Deploy(deployer); } catch { System.Console.Error.WriteLine(Resources.Log_DeploymentError); throw; } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } return(0); }
private static int PerformDeploy( string appRoot, string wapTargets, string deployer, string lockPath, IEnvironment env, IDeploymentSettingsManager settingsManager, TraceLevel level, ITracer tracer, ITraceFactory traceFactory, IOperationLock deploymentLock) { System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); // Skip SSL Certificate Validate if (System.Environment.GetEnvironmentVariable(SettingsKeys.SkipSslValidation) == "1") { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; } // Adjust repo path env.RepositoryPath = Path.Combine(env.SiteRootPath, settingsManager.GetRepositoryPath()); string statusLockPath = Path.Combine(lockPath, Constants.StatusLockFile); string hooksLockPath = Path.Combine(lockPath, Constants.HooksLockFile); IOperationLock statusLock = new LockFile(statusLockPath, traceFactory); IOperationLock hooksLock = new LockFile(hooksLockPath, traceFactory); IBuildPropertyProvider buildPropertyProvider = new BuildPropertyProvider(); ISiteBuilderFactory builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); var logger = new ConsoleLogger(); IRepository gitRepository; if (settingsManager.UseLibGit2SharpRepository()) { gitRepository = new LibGit2SharpRepository(env, settingsManager, traceFactory); } else { gitRepository = new GitExeRepository(env, settingsManager, traceFactory); } IServerConfiguration serverConfiguration = new ServerConfiguration(); IAnalytics analytics = new Analytics(settingsManager, serverConfiguration, traceFactory); IWebHooksManager hooksManager = new WebHooksManager(tracer, env, hooksLock); IDeploymentStatusManager deploymentStatusManager = new DeploymentStatusManager(env, analytics, statusLock); IDeploymentManager deploymentManager = new DeploymentManager(builderFactory, env, traceFactory, analytics, settingsManager, deploymentStatusManager, deploymentLock, GetLogger(env, level, logger), hooksManager); var step = tracer.Step(XmlTracer.ExecutingExternalProcessTrace, new Dictionary <string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { // although the api is called DeployAsync, most expensive works are done synchronously. // need to launch separate task to go async explicitly (consistent with FetchDeploymentManager) var deploymentTask = Task.Run(async() => await deploymentManager.DeployAsync(gitRepository, changeSet: null, deployer: deployer, clean: false)); #pragma warning disable 4014 // Track pending task PostDeploymentHelper.TrackPendingOperation(deploymentTask, TimeSpan.Zero); #pragma warning restore 4014 deploymentTask.Wait(); if (PostDeploymentHelper.IsAutoSwapEnabled()) { string branch = settingsManager.GetBranch(); ChangeSet changeSet = gitRepository.GetChangeSet(branch); IDeploymentStatusFile statusFile = deploymentStatusManager.Open(changeSet.Id); if (statusFile != null && statusFile.Status == DeployStatus.Success) { PostDeploymentHelper.PerformAutoSwap(env.RequestId, new PostDeploymentTraceListener(tracer, deploymentManager.GetLogger(changeSet.Id))).Wait(); } } } catch (Exception e) { tracer.TraceError(e); System.Console.Error.WriteLine(e.GetBaseException().Message); System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } return(0); }
private static int PerformDeploy( string appRoot, string wapTargets, string deployer, string lockPath, IEnvironment env, IDeploymentSettingsManager settingsManager, TraceLevel level, ITracer tracer, ITraceFactory traceFactory, IOperationLock deploymentLock) { System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); // Skip SSL Certificate Validate OperationClient.SkipSslValidationIfNeeded(); // Adjust repo path env.RepositoryPath = Path.Combine(env.SiteRootPath, settingsManager.GetRepositoryPath()); string statusLockPath = Path.Combine(lockPath, Constants.StatusLockFile); string hooksLockPath = Path.Combine(lockPath, Constants.HooksLockFile); IOperationLock statusLock = new LockFile(statusLockPath, traceFactory); IOperationLock hooksLock = new LockFile(hooksLockPath, traceFactory); IBuildPropertyProvider buildPropertyProvider = new BuildPropertyProvider(); ISiteBuilderFactory builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); var logger = new ConsoleLogger(); IRepository gitRepository; if (settingsManager.UseLibGit2SharpRepository()) { gitRepository = new LibGit2SharpRepository(env, settingsManager, traceFactory); } else { gitRepository = new GitExeRepository(env, settingsManager, traceFactory); } IServerConfiguration serverConfiguration = new ServerConfiguration(); IAnalytics analytics = new Analytics(settingsManager, serverConfiguration, traceFactory); IWebHooksManager hooksManager = new WebHooksManager(tracer, env, hooksLock); IDeploymentStatusManager deploymentStatusManager = new DeploymentStatusManager(env, analytics, statusLock); IAutoSwapHandler autoSwapHander = new AutoSwapHandler(env, settingsManager, traceFactory); var functionManager = new FunctionManager(env, traceFactory); IDeploymentManager deploymentManager = new DeploymentManager(builderFactory, env, traceFactory, analytics, settingsManager, deploymentStatusManager, deploymentLock, GetLogger(env, level, logger), hooksManager, functionManager); var step = tracer.Step(XmlTracer.ExecutingExternalProcessTrace, new Dictionary <string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.DeployAsync(gitRepository, changeSet: null, deployer: deployer, clean: false) .Wait(); string branch = settingsManager.GetBranch(); ChangeSet changeSet = gitRepository.GetChangeSet(branch); IDeploymentStatusFile statusFile = deploymentStatusManager.Open(changeSet.Id); if (statusFile != null && statusFile.Status == DeployStatus.Success) { autoSwapHander.HandleAutoSwap(changeSet.Id, deploymentManager.GetLogger(changeSet.Id), tracer).Wait(); } } catch (Exception e) { tracer.TraceError(e); System.Console.Error.WriteLine(e.GetBaseException().Message); System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } return(0); }
static int Main(string[] args) { // Turn flag on in app.config to wait for debugger on launch if (ConfigurationManager.AppSettings["WaitForDebuggerOnStart"] == "true") { while (!Debugger.IsAttached) { System.Threading.Thread.Sleep(100); } } if (args.Length < 2) { System.Console.WriteLine("Usage: kudu.exe appRoot wapTargets [deployer]"); return 1; } // The post receive hook launches the exe from sh and intereprets newline differently. // This fixes very wacky issues with how the output shows up in the conosle on push System.Console.Error.NewLine = "\n"; System.Console.Out.NewLine = "\n"; System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); var appRoot = args[0]; var wapTargets = args[1]; string deployer = args.Length == 2 ? null : args[2]; string nugetCachePath = null; IEnvironment env = GetEnvironment(appRoot, nugetCachePath); // Setup the trace string tracePath = Path.Combine(env.RootPath, Constants.TracePath, Constants.TraceFile); var tracer = new Tracer(tracePath); var traceFactory = new TracerFactory(() => tracer); // Calculate the lock path string lockPath = Path.Combine(env.SiteRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); var deploymentLock = new LockFile(traceFactory, deploymentLockPath); var fs = new FileSystem(); var buildPropertyProvider = new BuildPropertyProvider(); var builderFactory = new SiteBuilderFactory(buildPropertyProvider, env); var serverRepository = new GitDeploymentRepository(env.RepositoryPath, traceFactory); var settings = new XmlSettings.Settings(GetSettingsPath(env)); var settingsManager = new DeploymentSettingsManager(settings); var logger = new ConsoleLogger(); var deploymentManager = new DeploymentManager(serverRepository, builderFactory, env, fs, traceFactory, settingsManager, deploymentLock, logger); var step = tracer.Step("Executing external process", new Dictionary<string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.Deploy(deployer); } catch { System.Console.Error.WriteLine(Resources.Log_DeploymentError); throw; } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return 1; } return 0; }
static int Main(string[] args) { // Turn flag on in app.config to wait for debugger on launch if (ConfigurationManager.AppSettings["WaitForDebuggerOnStart"] == "true") { while (!Debugger.IsAttached) { System.Threading.Thread.Sleep(100); } } if (args.Length < 2) { System.Console.WriteLine("Usage: kudu.exe appRoot wapTargets [deployer]"); return(1); } // The post receive hook launches the exe from sh and intereprets newline differently. // This fixes very wacky issues with how the output shows up in the conosle on push System.Console.Error.NewLine = "\n"; System.Console.Out.NewLine = "\n"; System.Environment.SetEnvironmentVariable("GIT_DIR", null, System.EnvironmentVariableTarget.Process); var appRoot = args[0]; var wapTargets = args[1]; string deployer = args.Length == 2 ? null : args[2]; string nugetCachePath = null; IEnvironment env = GetEnvironment(appRoot, nugetCachePath); var settings = new XmlSettings.Settings(GetSettingsPath(env)); var settingsManager = new DeploymentSettingsManager(settings); // Setup the trace TraceLevel level = settingsManager.GetTraceLevel(); var tracer = GetTracer(env, level); var traceFactory = new TracerFactory(() => tracer); // Calculate the lock path string lockPath = Path.Combine(env.SiteRootPath, Constants.LockPath); string deploymentLockPath = Path.Combine(lockPath, Constants.DeploymentLockFile); var deploymentLock = new LockFile(traceFactory, deploymentLockPath); var fs = new FileSystem(); var buildPropertyProvider = new BuildPropertyProvider(); var serverRepository = new GitDeploymentRepository(env.RepositoryPath, env.SiteRootPath, traceFactory); var builderFactory = new SiteBuilderFactory(settingsManager, buildPropertyProvider, env); var logger = new ConsoleLogger(); var deploymentManager = new DeploymentManager(serverRepository, builderFactory, env, fs, traceFactory, settingsManager, deploymentLock, GetLogger(env, level, logger)); var step = tracer.Step("Executing external process", new Dictionary <string, string> { { "type", "process" }, { "path", "kudu.exe" }, { "arguments", appRoot + " " + wapTargets } }); using (step) { try { deploymentManager.Deploy(deployer); } catch { System.Console.Error.WriteLine(Resources.Log_DeploymentError); throw; } } if (logger.HasErrors) { System.Console.Error.WriteLine(Resources.Log_DeploymentError); return(1); } return(0); }
/// <summary> /// Load your modules or register your services here! /// </summary> /// <param name="kernel">The kernel.</param> private static void RegisterServices(IKernel kernel) { IEnvironment environment = GetEnvironment(); var propertyProvider = new BuildPropertyProvider(); kernel.Bind<ISettings>().ToMethod(context => new XmlSettings.Settings(GetSettingsPath(environment))); kernel.Bind<IBuildPropertyProvider>().ToConstant(propertyProvider); kernel.Bind<IEnvironment>().ToConstant(environment); kernel.Bind<IRepositoryManager>().ToMethod(context => new RepositoryManager(environment.RepositoryPath)); kernel.Bind<ISiteBuilderFactory>().To<SiteBuilderFactory>(); kernel.Bind<IDeploymentManager>().To<DeploymentManager>() .InSingletonScope() .OnActivation(SubscribeForDeploymentEvents); kernel.Bind<IDeploymentSettingsManager>().To<DeploymentSettingsManager>(); kernel.Bind<IEditorFileSystemFactory>().To<FileSystemFactory>(); kernel.Bind<IGitServer>().ToMethod(context => new GitExeServer(environment.RepositoryPath)); kernel.Bind<IUserValidator>().To<SimpleUserValidator>(); kernel.Bind<IHgServer>().To<Kudu.Core.SourceControl.Hg.HgServer>().InSingletonScope(); kernel.Bind<IServerConfiguration>().To<ServerConfiguration>().InSingletonScope(); kernel.Bind<IFileSystem>().To<FileSystem>(); kernel.Bind<ICommandExecutor>().ToMethod(context => GetComandExecutor(environment, context)) .InSingletonScope() .OnActivation(SubscribeForCommandEvents); }
/// <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)); }