Пример #1
0
        public bool Update()
        {
            Log.Info("Checking for updates");
            if (!Config.Enabled)
            {
                Log.Info("Update Manager Disabled via config file.");
                return(false);
            }
            var factory = AppUpdateFactory.Setup(DoUpdate);
            var ret     = factory.Execute();

            Log.Info(ret?"Update available":"Update not available");
            return(ret);
        }
Пример #2
0
        private static void Main(string[] args)
        {
            try
            {
                // select a profile from the cmdline args /profile:[profile] switch
                CmdLine.Init(args);

                string package;

                if (CmdLine.Value(CmdLine.SwitchNames.Update, out package))
                {
                    string feed;
                    CmdLine.Value(CmdLine.SwitchNames.Feed, out feed);

                    if (string.IsNullOrWhiteSpace(package))
                    {
                        // /update switch applied
                        // general update everything installed
                        if (AppUpdateFactory.Setup(cfg => cfg
                                                   .Update("Wolfpack", cfg.CurrentAppVersion(), feed)
                                                   .TargetFrameworkVersion45()
                                                   .UseLogger(new FileLogger(Level.Debug, @"sidewinder.log")))
                            .Execute())
                        {
                            Logger.Debug("*** UPDATE AVAILABLE!! SHUTTING DOWN ***");
                            return;
                        }
                    }
                    else
                    {
                        // /update:package switch applied
                        // update this specific package only
                        if (AppUpdateFactory.Setup(cfg => cfg.Update(new TargetPackage
                        {
                            Name = package,
                            NuGetFeedUrl = feed,
                            UpdateDependencies = true
                        })
                                                   .JustThesePackages()
                                                   .UseLogger(new FileLogger(Level.Debug, @"sidewinder.log"))
                                                   .TargetFrameworkVersion45())
                            .Execute())
                        {
                            Logger.Debug("*** PACKAGE IS AVAILABLE!! SHUTTING DOWN TO INSTALL IT ***");
                            return;
                        }
                    }
                }

                Container.Initialise();

                var profile = LoadProfile();
                var role    = profile.Role;

                HostFactory.Run(
                    config =>
                {
                    config.SetDisplayName("Wolfpack Agent");
                    config.SetServiceName("Wolfpack");
                    config.SetDescription("Wolfpack Agent Service");

                    string username;
                    string password;

                    if (CmdLine.Value(CmdLine.SwitchNames.Username, out username) &&
                        CmdLine.Value(CmdLine.SwitchNames.Password, out password))
                    {
                        Logger.Debug("Running As: {0}", username);
                        config.RunAs(username, password);
                    }

                    config.Service <IRolePlugin>(service =>
                    {
                        service.ConstructUsing(factory => role);
                        service.WhenStarted(s => s.Start());
                        service.WhenStopped(s => s.Stop());
                    });

                    config.ApplyCommandLine(string.Join(" ", CmdLine.Expanded.ToArray()));
                });

                Environment.ExitCode = 0;
            }
            catch (Exception ex)
            {
                var msg = string.Format("Wolfpack System Failure. IncidentId:={0}; Details:={1}",
                                        Guid.NewGuid(),
                                        ex);

                Logger.Error(msg);
                Environment.ExitCode = 1;
            }
        }