问题标签 [topshelf]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2231 浏览

ninject - Ninject Topshelf Microsoft.Owin.Hosting

如何利用 Topshelf.Ninject 并合并 OwinNinjectDependencyResolver(来自 Ninject.Web.WebApi.OwinHost)?

我可以让它工作,但我需要两次实例化 Ninject 内核(一次用于 Topshelf,一次用于我的 HttpConfiguration.DependencyResolver。这似乎不是使用 Ninject 的正确方法。

与此特定设计相关的任何帮助或示例代码都会非常有帮助。

0 投票
2 回答
3606 浏览

c# - 以编程方式重新启动 ac# TopShelf 服务

我发现自己处于一个可怕的境地,我有一个顶级服务,它使用一个存在内存问题的 c++ 库。由于我发现自己所在的地方的这种意愿,我想在它的活动暂停期间不时地调用 TopShelf 重新启动服务,除了“让世界恢复正常”之外没有其他原因。

是否有任何 TopShelf API 允许这样做?我似乎在文档中找不到任何内容。

0 投票
1 回答
1867 浏览

windows-services - 如何停止 TopShelf 使用 log4net 创建多个日志文件?

我的 TopShelf 托管的 Windows 服务之一是创建如下所示的重复日志文件:

之前在 StackOverflow 上已经描述了一个类似的问题 - 10639682中的解决方案对我不起作用,但579688表明它可能是由两次初始化日志系统引起的。

我正在使用 TopShelf Log4Net 插件,但我也在做自己的 log4net 日志记录,并且需要ILog在服务实际启动之前访问实例,所以我的代码如下所示:

我做了一些挖掘,似乎x.UseLog4Net()在我的RunService方法中调用实际上XmlConfigurator.Configure() 在运行- 请参阅TopShelf 代码中的Log4NetLogWriterFactory,第 62 行

所以...

  1. 我认为XmlConfigurator.Configure()两次调用可能是导致我的重复日志文件问题的原因是否正确?
  2. 如果是这样 - 我如何将现有配置注入 TopShelf,或者在我启动服务之前让 TopShelf 初始化运行,以便我可以在服务启动之前开始记录?
0 投票
1 回答
8394 浏览

c# - Executing multiple Quartz.NET jobs with Topshelf

I am attempting to run multiple jobs with Quartz.NET and Topshelf using C#.

Using the above code, only the execute method in TypeB gets executed. I have also tried:

With this code, only the execute method in TypeB is called. Both my classes TypeA and TypeB have 'Execute' methods which are the entry points for each class (which do get called if they are part of a job on their own). It seems that whichever service code is second is the one that is always called - if I swap the order of these two ScheduleQuartzJobAsService calls it is always the class in the second call that is executed.

How can I write my HostFactory.Run method so both jobs are executed concurrently?

0 投票
1 回答
347 浏览

topshelf - 为什么topshelf在执行命令后等待输入?

我有以下脚本来安装 topshelf 服务:

当我运行这个脚本时,我必须在每一步之间按回车键。有没有解决的办法?

0 投票
1 回答
1499 浏览

.net - 如何启动 HostFactory.New topshelf 服务

以下是HostFactory使用New方法创建和声明服务的示例:http: //docs.topshelf-project.com/en/latest/configuration/config_api.html#simple-service

但我不知道如何立即启动此服务(如HostFactory.Run(...))?

0 投票
1 回答
2610 浏览

topshelf - TopShelf ConstructUsing vs WhenStarted

我想问一下ConstructUsing应该做哪些操作,WhenStarted应该做哪些操作。事实上,通常放在构造函数中的东西,比如配置读取,服务初始化应该放在WhenStarted IMO中,以便在服务重启期间刷新所有东西,那么ConstructUsing还剩下什么?只是更新课程,仅此而已?但在那种情况下,为什么不在WhenStarted 中更新呢?

提前致谢

0 投票
1 回答
739 浏览

c# - Topshelf WhenContinue 不工作

当我在配置中继续添加时,Topshelf 不起作用。它适用于启动和停止方法。我在 continue 方法中没有任何代码会阻止它运行(简单的 console.writeline )

我错过了什么?

它编译得很好。它没有调用我的任何方法。我看到控制台闪烁并消失。我什至无法阅读该控制台上的内容。如果我注释掉 s.WhenContinued(v => v.Continue()); 它工作正常

0 投票
2 回答
3330 浏览

c# - 如何开始使用 TopShelf

我最近发现了 TopShelf。从我读过的所有内容来看,它看起来很酷。唯一的问题是我无法使用它。我一定错过了什么。下面是我的代码。

你可以看到它有点不完整。当我尝试为 ConstructUsing、WhenStarted 和 WhenStopped 设置“s”对象的属性时,Visual Studio 没有推断出正确的类型。我是 lambda 表达式的新手,甚至是 TopShelf 的新手,所以我不确定我在做什么。

我正在使用TopShelf 文档中的这个页面来帮助我入门。它看起来很简单,所以我不确定我错过了什么。


更新代码


0 投票
2 回答
3517 浏览

c# - TopShelf 服务因异常而陷入“停止”状态

我有一个 TopShelf (3.1.3) 服务,它在引发异常时处于“停止”状态。因此,不会调用任何服务恢复步骤,并且只有在通过“taskkill”手动终止服务时才能成功卸载服务。

在 TopShelf 中处理异常的推荐方法是什么?我不想简单地吞下/记录异常并继续。理想情况下,对 hostControl.Stop 的调用确实会将服务置于“停止”状态,但事实并非如此。

该线程提出了一个类似的问题,但它没有提供答案: 如何捕获异常并停止 Topshelf 服务?

想法?