Example #1
0
        static void Main(string[] args)
        {
            HostFactory.Run(factory =>
            {
                EsLogger.SetupGlobalLogger();

                Log.Logger.Information("Ready to start hostfactory");

                Log.Logger.Information("hostfactory 1");
                factory.Service <ServiceHost>(service =>
                {
                    service.ConstructUsing(name => new ServiceHost());
                    service.WhenStarted(sh => sh.Start());
                    service.WhenShutdown(sh => sh.Shutdown());
                    service.WhenStopped(sh => sh.Stop());
                });
            });
        }
Example #2
0
        private static void Main(string[] args)
        {
            EsLogger.SetupGlobalLogger();

            Log.Logger.Information("Ready to start hostfactory");

            HostFactory.Run(factory =>
            {
                //factory.OnException(exception => { Log.Logger.Error(exception, "Topshelf xception"); });
                factory.Service <ServiceHost>(service =>
                {
                    service.ConstructUsing(name => new ServiceHost());
                    service.WhenStarted(sh => sh.Start());
                    service.WhenShutdown(sh => sh.Shutdown());
                    service.WhenStopped(sh => sh.Stop());
                });
                factory.SetDescription(ConfigurationManager.AppSettings["version"]);
            });
        }
Example #3
0
        private static int Main(string[] args)
        {
            // Create Logger
            EsLogger.SetupGlobalLogger();

            Log.Logger.Information("Running Migrations");

            var connectionString =
                args.FirstOrDefault()
                ?? ConfigurationManager.ConnectionStrings["shiftDriversDb"].ConnectionString;

            EnsureDatabase.For.SqlDatabase(connectionString);

            var upgrader =
                DeployChanges.To
                .SqlDatabase(connectionString)
                .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
                .LogToConsole()
                .Build();

            var result = upgrader.PerformUpgrade();

            if (!result.Successful)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(result.Error);
                Console.ResetColor();
#if DEBUG
                Console.ReadLine();
#endif
                return(-1);
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Success!");
            Console.ResetColor();
            return(0);
        }