gpt4 book ai didi

.net - 如何配置 TopShelf 以作为 ServiceAccount.NetworkService 运行服务?

转载 作者:行者123 更新时间:2023-12-05 00:06:25 25 4
gpt4 key购买 nike

如何配置 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com