代码之家  ›  专栏  ›  技术社区  ›  Simon Randy Burden

如何将topshelf配置为以serviceaccount.networkservice的形式运行服务?

  •  4
  • Simon Randy Burden  · 技术社区  · 14 年前

    如何将topshelf配置为以serviceaccount.networkservice的形式运行服务?

    https://github.com/Topshelf/Topshelf

    1 回复  |  直到 13 年前
        1
  •  7
  •   Travis    14 年前

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