Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Service to Linux Daemon

I am writing a portable service/daemon using .NET 3.5, my windows service is running, but I was wondering about the mono port...

Mono-service is what I am looking for if I understand correctly. How exactly does this work though? I assume I need mono compatible code throughout my service, right? For example, I am using SQLite. Is it correct that in order to use this with mono I should refactor my code to use mono namespaces etc, such as Mono.Data.SQLite? May I still use Settings.settings?

Also, I've read that daemons don't implement onStart/Stop methods, so do I need to change my code to run under mono/linux? i.e. is it ok to have these methods in my code, and ok to run ServiceBase.Run()? Does Mono-service accommodate these?

like image 655
marked Avatar asked Jul 05 '11 14:07

marked


People also ask

Can I build a Linux daemon as a Windows service?

So if you end up having to build a Linux daemon which also works as a Windows Service, you might want to add a middle layer library which is common service functionality and you just host it in a different project depending on your platform.

How to run NET Core process as a daemon on Linux?

When you want to run .NET Core process as a daemon on Red Hat Enterprise Linux, you can create a custom systemd unit. Today I'll write about two examples of custom systemd unit for .NET Core. The one is a oneshot type for running a .NET Core console application and the other is a simple type for running an ASP.NET Core Web application.

How to run a daemon on Red Hat Enterprise Linux with systemd?

When you want to run .NET Core process as a daemon on Red Hat Enterprise Linux, you can create a custom systemd unit. Today I’ll write about two examples of custom systemd unit for .NET Core. The one is a oneshot type for running a .NET Core console application and the other is a simple type for running an ASP.NET Core Web application.

What are daemons in a server?

Daemons are as essential to servers as caffeine and pizza are to developers. The executables run as services on a server waiting to receive input usually from a network call, and respond to it by providing something back to the the user who called it. . NET Core is the venerable cross-platform development stack for Linux, Mac, and Windows.


1 Answers

You should create your programs from the beginning for use with Windows and Linux.

You need Visual Studio with Mono Tools or the free MonoDevelop-IDE to create a Mono-Application. MonoDevelop can import your Visual Studio Project. This IDE helps you to get the right namespaces.

Use Mono-Service to run your Assembly as daemon. Linux Daemons are using Signals to communicate with the System. Please read the documentation.

We already had a similar question, so please read this to see, how to process Unix-Signals.

like image 59
DiableNoir Avatar answered Sep 27 '22 23:09

DiableNoir