问题描述
我正在尝试为 linux 编写 Mono C# 守护程序.
I'm trying to write a Mono C# daemon for linux.
我想在它完成处理时启动和停止它,而不是仅仅终止进程.
I'd like to do a starts and stops of it when its done processing instead of just killing the process.
有人有这方面的例子吗?
Does anyone have any examples of this?
我想出了如何在 debian 中使用 start-stop-daemon --background,所以我想我现在就使用它.
I figured out how to use start-stop-daemon --background in debian, so I think I'll just use that for now.
我也在 java 中实现这个,他们有这个很好的 addShutdownHook 可以捕获终止应用程序.我需要花更多的时间来整理单声道服务的依赖关系,或者找到一种方法来捕获应用程序终止.
I'm implementing this in java as well and they have this nice addShutdownHook that catches terminating the app. I need to spend a little more time sorting out the dependencies for mono service, or find a way to catch app termination.
有 SessionEnd 事件,但这仅适用于服务而不是控制台应用程序
There is the SessionEnd event, but thats only available for services and not console apps
答案:在linux上使用mono-service包装一个windows服务
推荐答案
你应该实现一个服务并使用单服务.谷歌一下,你会发现几个例子.
You should implement a service and use mono-service. Google for it and you'll find several examples.
这篇关于如何编写 Mono 守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!