如何使用Topshelf命令行安装服务恢复?

时间:2016-02-04 19:38:32

标签: command-line windows-services topshelf

目前,我使用命令行安装我的Topshelf Windows服务

my.exe install -instance:1 -username:bob -password:pwd

是否有人知道如果可能包含服务恢复选项? 我在命令行参考中看不到任何内容 http://docs.topshelf-project.com/en/latest/overview/commandline.html

如果不支持,我的选择是什么? 您可以在TopShelf Windows服务上使用sc.exe(服务控制管理器)吗? https://technet.microsoft.com/en-us/library/cc742019.aspx

或者我应该把它搞砸并使用应用程序配置文件将这些设置放入,并读取值以编程方式执行此操作? http://docs.topshelf-project.com/en/latest/configuration/config_api.html#id1

HostFactory.New(x =>
{
    x.EnableServiceRecovery(rc =>
    {
        rc.RestartService(1); // restart the service after 1 minute
        rc.RestartSystem(1, "System is restarting!"); // restart the system after 1 minute
        rc.RunProgram(1, "notepad.exe"); // run a program
        rc.SetResetPeriod(1); // set the reset interval to one day
    })
});

谢谢!

1 个答案:

答案 0 :(得分:1)

所以,目前这还不可行。但我鼓励你打开一个执行此操作的拉取请求。我不记得其他人要求这样做,但这似乎是一个合理的要求 - 所以至少在FsCheck的问题跟踪器中打开一个问题。

相关问题