You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB
C#

5 years ago
using System;
using Topshelf;
using System.Security.Cryptography.X509Certificates;
namespace TopshelfStudy.NetCoreDemo
{
class Program
{
static void Main(string[] args)
{
var topshelfExitCode = HostFactory.Run(config =>
{
//使用NLog日志
config.UseNLog(NLog.LogManager.LogFactory);
//服务配置
config.Service<TopshelfService>(s =>
{
s.ConstructUsing(name => new TopshelfService());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
//运行服务帐户
config.RunAsLocalSystem();
//服务名(所有服务中唯一)
config.SetServiceName("AIoT.Service.Demo");
//服务显示名
config.SetDisplayName("AIoT服务测试");
//服务描述
config.SetDescription("这是一个AIoT服务测试例子使用Topshelf类库方便调试");
});
//退出码
Environment.ExitCode = (int)Convert.ChangeType(topshelfExitCode, topshelfExitCode.GetTypeCode());
}
}
}