Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I code a Mono Daemon

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?

Edit: I figured out how to use start-stop-daemon --background in debian, so I think I'll just use that for now.

Edit: 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.

There is the SessionEnd event, but thats only available for services and not console apps

Answer: using mono-service to wrap a windows service on linux

like image 859
Scott Cowan Avatar asked Oct 09 '08 09:10

Scott Cowan


1 Answers

To receive notifications in the Unix way, that is using signals, you want to use the Mono.Unix.UnixSignal for each signal that you plan on receiving and then call UnixSignal.WaitAny () on an array of signals.


You would typically do this on a separate thread.

like image 134
miguel.de.icaza Avatar answered Sep 25 '22 13:09

miguel.de.icaza