welsonjs/WelsonJS.Toolkit/WelsonJS.Service/Program.cs

47 lines
1.4 KiB
C#
Raw Normal View History

using Microsoft.Extensions.Logging;
using System;
using System.IO;
2024-07-22 07:04:40 +00:00
using System.ServiceProcess;
using WelsonJS.Service.Logging;
2024-07-22 07:04:40 +00:00
namespace WelsonJS.Service
{
internal static class Program
{
private static ILogger logger;
2024-07-22 07:04:40 +00:00
/// <summary>
/// 해당 애플리케이션의 주 진입점입니다.
2024-07-22 07:04:40 +00:00
/// </summary>
///
2024-07-22 11:15:31 +00:00
static void Main(string[] args)
2024-07-22 07:04:40 +00:00
{
// create the logger
ILoggerFactory factory = LoggerFactory.Create(builder => builder.AddConsole());
factory.AddDirectory(Path.GetTempPath());
logger = factory.CreateLogger("welsonjs");
// create the service
2024-07-22 11:15:31 +00:00
if (Environment.UserInteractive)
2024-07-22 07:04:40 +00:00
{
2024-07-29 12:43:14 +00:00
Console.WriteLine("WelsonJS Service Application (User Interactive Mode)");
Console.WriteLine("https://github.com/gnh1201/welsonjs");
Console.WriteLine();
Console.WriteLine("Service is running...");
ServiceMain svc = new ServiceMain(args, logger);
svc.TestStartupAndStop();
2024-07-22 11:15:31 +00:00
}
else
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new ServiceMain(args, logger)
2024-07-22 11:15:31 +00:00
};
ServiceBase.Run(ServicesToRun);
}
2024-07-22 07:04:40 +00:00
}
}
}