4
如何配置TopShelf作爲ServiceAccount.NetworkService運行服務?如何配置TopShelf作爲ServiceAccount.NetworkService運行服務?
https://github.com/Topshelf/Topshelf
如何配置TopShelf作爲ServiceAccount.NetworkService運行服務?如何配置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);
您也可以使用命令行選項覆蓋配置,例如--networkservice,--localservice或--interactive,以便在安裝服務期間提示輸入用戶名/密碼。 – 2011-09-07 02:03:20