private static void Main()

in DeviceBridge/Program.cs [27:71]


        private static void Main(string[] args)
        {
            var logger = NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();

            // In setup mode only run setup tasks without bringing up the server.
            if (args.Contains("--setup"))
            {
                logger.Info("Executing in setup mode.");

                try
                {
                    var dbSchemaSetup = new DbSchemaSetup();
                    dbSchemaSetup.SetupDbSchema().Wait();

                    var encryptionSetup = new EncryptionSetup();
                    encryptionSetup.Reencrypt().Wait();

                    return;
                }
                finally
                {
                    NLog.LogManager.Shutdown();
                }
            }

            try
            {
                CreateHostBuilder(args).Build().Run();
            }
            catch (Exception e)
            {
                // If the storage setup is not complete, wait 30 seconds before exiting. This gives more time for setup to finish before next execution is attempted.
                if (e.InnerException is StorageSetupIncompleteException)
                {
                    logger.Info("ERROR: DB setup is not complete. Please make sure that schema setup task finishes successfully. Process will exit in 30 seconds...");
                    Thread.Sleep(30000);
                }

                logger.Error(e);
            }
            finally
            {
                NLog.LogManager.Shutdown();
            }
        }