static void Main(string[] args) { var config = new ConfigurationBuilder() .SetBasePath(new FileInfo(Assembly.GetEntryAssembly().Location).DirectoryName) .AddJsonFile("appsettings.json", true) .Build(); var logBuild = new LoggerConfiguration() .WriteTo.Console() .WriteTo.RollingFile(Path.Combine("logs", "dotnet.log"), retainedFileCountLimit: 10, fileSizeLimitBytes: 1024 * 30) .MinimumLevel.Verbose(); Log.Logger = logBuild.CreateLogger(); var webHost = BuildWebHost(config["server:port"]); if (args.Length > 0 && args[0] == "develop") { ServerInfo.DriverDirectoy = args[1]; ServerInfo.DriverPattern = args[2]; ServerInfo.IsInDevelopmentMode = true; } else { ServerInfo.DriverDirectoy = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; } var logger = SystemLogger.Instance; logger.LogInformation($"Starting...Version {ServerInfo.GetServerVersion()}, Datetime {ServerInfo.StartupTime}. Running .NET Core Version {GetNetCoreVersion()}"); var db = webHost.Services.GetRequiredService <AutomaticaContext>(); DatabaseInit.EnusreDatabaseCreated(webHost.Services); var serverId = db.Settings.SingleOrDefault(a => a.ValueKey == "ServerUID"); if (serverId == null) { var guid = Guid.NewGuid(); db.Settings.Add(new Setting { ValueKey = "ServerUID", Value = guid, Group = "SERVER.SETTINGS", IsVisible = false, Type = (long)PropertyTemplateType.Text }); ServerInfo.ServerUid = guid; db.SaveChanges(); } else { ServerInfo.ServerUid = new Guid(serverId.ValueText); } webHost.Services.GetService <DiscoveryService>(); webHost.Run(); logger.LogInformation("Stopped..."); }
static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.Console() .MinimumLevel.Verbose() .CreateLogger(); Log.Logger.Information("Starting Automatica.Core.CI database tool"); var config = new ConfigurationBuilder() .SetBasePath(new FileInfo(Assembly.GetEntryAssembly().Location).DirectoryName) .AddJsonFile("appsettings.json", true) .Build(); var fi = new FileInfo(Assembly.GetEntryAssembly().Location); if (File.Exists(Path.Combine(fi.DirectoryName, DatabaseConstants.DatabaseInitName))) { File.Delete(Path.Combine(fi.DirectoryName, DatabaseConstants.DatabaseInitName)); } var webHost = BuildWebHost(args); string loadDirectory = ""; if (args.Length > 0) { loadDirectory = args[0]; } else { loadDirectory = fi.DirectoryName; } DatabaseInit.EnusreDatabaseCreated(webHost.Services); var server = new CoreServer(webHost.Services); server.Load(loadDirectory, "*.dll"); Console.WriteLine($"Done...."); Environment.Exit(0); }