开发者

How to configure TopShelf to run a service as ServiceAccount.NetworkService?

How to configure TopSh开发者_如何学运维elf to run a service as ServiceAccount.NetworkService?

https://github.com/Topshelf/Topshelf


The new location of TopShelf, http://github.com/Topshelf/Topshelf, has been updated with a patch allowing this behavior.

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜