如何配置 TopShelf 以作为 ServiceAccount.NetworkService 运行服务?
https://github.com/Topshelf/Topshelf
最佳答案
TopShelf 的新位置,http://github.com/Topshelf/Topshelf , 已经更新了一个允许这种行为的补丁。
RunConfiguration cfg = RunnerConfigurator.New(x =>
{
x.AfterStoppingTheHost(h => { Console.WriteLine("AfterStop called invoked, services are stopping"); });
x.ConfigureService<TownCrier>(s =>
{
s.Named("tc");
s.HowToBuildService(name=> new TownCrier());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
// Running as the network service account
x.RunAsNetworkService();
x.SetDescription("Sample Topshelf Host");
x.SetDisplayName("Stuff");
x.SetServiceName("stuff");
});
Runner.Host(cfg, args);
关于.net - 如何配置 TopShelf 以作为 ServiceAccount.NetworkService 运行服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3244120/