kmProcessServer/Program.cs

33 lines
1.0 KiB
C#
Raw Normal View History

2025-11-04 04:21:57 -05:00
using Topshelf;
using log4net;
using log4net.Config;
using System.Reflection;
namespace kmProcessServer;
internal class Program
{
internal static string AppPath = AppDomain.CurrentDomain.BaseDirectory.Trim();
internal static string AppName = Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName.Trim());
internal static string MachineName = Environment.MachineName.Trim();
public static bool isExiting = false;
static void Main(string[] args)
{
var logRepo = LogManager.GetRepository(Assembly.GetEntryAssembly());
XmlConfigurator.Configure(logRepo, new FileInfo(Path.Combine(AppPath, "log4net.config")));
GlobalContext.Properties["Application"] = AppName;
var rc = HostFactory.Run(x => {
x.Service<ServiceMain>();
x.EnableServiceRecovery(r => r.RestartService(TimeSpan.FromSeconds(15)));
x.SetServiceName("kmAtomicTime2");
x.StartAutomaticallyDelayed();
x.SetDescription("Serves as a host to several Micro Services that the company runs.");
x.UseLog4Net();
});
}
}