Migración a percona
This commit is contained in:
51
ServicioGestionAsegasa/Program.cs
Normal file
51
ServicioGestionAsegasa/Program.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using Servicio_Gestion_Asegasa;
|
||||
using System.Reflection;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Serilog.Debugging.SelfLog.Enable(msg => Console.Error.WriteLine(msg));
|
||||
bdAsegasa.db.Utilidades.VersionPrograma = tsUtilidades.Utilidades.ExtraeValorCadena(Assembly.GetExecutingAssembly().FullName, "Version");
|
||||
// Configura Serilog antes de construir el host
|
||||
string path = "";
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\ServicioGestionAsegasa\ServicioGestionAsegasa.log";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
path = @"/var/log/ServicioGestionAsegasa/ServicioGestionAsegasa.log";
|
||||
}
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.Information()
|
||||
.WriteTo.File(path, rollingInterval: RollingInterval.Day)
|
||||
.CreateLogger();
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
host.Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
IConfiguration configuration = hostContext.Configuration;
|
||||
Configuracion options = configuration.GetSection("Configuracion").Get<Configuracion>();
|
||||
|
||||
services.AddSingleton(options);
|
||||
|
||||
// Solo registrar WindowsService si estamos en Windows
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
services.AddWindowsService(config =>
|
||||
{
|
||||
config.ServiceName = "ServicioGestionAsegasa";
|
||||
});
|
||||
}
|
||||
|
||||
services.AddHostedService<Worker>();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user