private static void RunCore(DeployContext context)
        {
            Beep(context, "start");

            var plan = ActionPlan.Build(context.RunContext);

            var root = new ExecutionNode("Begin deploy", "Deploy completed");
            root.AddChild(BuildRestoreDatabasesNode(plan.Databases, context));

            foreach (var release in plan.Releases)
            {
                var releaseNode = BuildReleaseNode(release, context);
                root.AddChild(releaseNode);
            }

            var hash = StateHash.Empty;
            try
            {
                StateHash startingHash = null;
                if (context.Resume)
                {
                    startingHash = LoadResumeHash(context);
                }

                var improved = root.Calculate(context, hash, startingHash, context.CacheManager);
                if (improved.Item3)
                {
                    root = improved.Item1;
                    if (improved.Item4 != null)
                    {
                        context.CacheManager.UpdateHits(context.ApplicationContext.ProjectConfig.Databases.Select(x => Tuple.Create(x, improved.Item4)));
                    }
                }

                var sink = new CheckingRequirementSink(context.ApplicationContext.Log);
                root.GetRequirements(sink);
                if (sink.Finish())
                    throw new SoftFailureException("Command aborted due to unmet requirements.");

                root.Run(context, startingHash ?? hash, context.CacheManager);

                if (!context.DryRun)
                    CleanResumeHash(context);
            }
            catch (SoftFailureException ex)
            {
                Beep(context, "error");
                throw new SoftFailureException("Blocking error detected", ex);
            }

            Beep(context, "success");
        }
예제 #2
0
        private static void RunCore(RunContext context)
        {
            var plan = ActionPlan.Build(context);

            var root = new ExecutionNode(string.Format("Running '{0}' action", context.Action), "Success!");
            foreach (var release in plan.Releases)
            {
                root.AddChild(BuildReleaseNode(context, release));
            }

            var sink = new CheckingRequirementSink(context.ApplicationContext.Log);
            root.GetRequirements(sink);
            if (sink.Finish())
                throw new SoftFailureException("Command aborted due to unmet requirements.");

            root.Run(context);
        }