加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何配置TopShelf以将服务作为ServiceAccount.NetworkService运

发布时间:2020-12-14 01:36:46 所属栏目:Windows 来源:网络整理
导读:如何配置TopShelf以将服务作为ServiceAccount.NetworkService运行? https://github.com/Topshelf/Topshelf 解决方法 TopShelf的新位置 http://github.com/Topshelf/Topshelf已更新为允许此行为的补丁. RunConfiguration cfg = RunnerConfigurator.New(x ={
如何配置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);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读