How to use mono to migrate. NET Windows service programs to Linux

Source: Internet
Author: User
Tags stdin

How to migrate A. NET Windows Service application to Linux using mono?

Written in the first place: The reason why the Windows program to be migrated to Linux, mainly because of some cost problems, this is not much explained.

How to migrate a Windows service program that was previously written with. NET to run on Linux. The answer is there are many kinds of, today I only mention mono (I only experiment mono, hehe).

How to deploy Mono in Linux, and successfully run the. NET program, but also ask you a lot of inquiries, I also only build success in this area, encountered the problem is not enough, do not mislead everyone.

Using mono to run a. NET program on Linux is still easy, but how to run a background service program, today is also a fee Dickens, and finally draw on a stackoverflow in the answer to explain the problem.

Under Linux, deamons is simple background processes. No Special control methods (e.g start() , stop() ) is used as in Windows. Build your service as a simple (console) application, and run it in the background. Use a tool daemonize -like-to-run a program as a Unix daemon, and remember to specify as the program to be mono activated.

As noted by others, Mono-service are a host to run services built with the ServiceProcess assembly. Services built for Windows can use this method to run unmodified under Linux. You can control the "service by" sending signals to the process (see Mans page).

My English is not so good, I can only understand the meaning of it. Inside the taste of everyone can savor their own.

The general meaning is that the first way: Under Linux, Windows Services can be transformed into a console program to run. The second way: use Mono-service to run the Windows service program. The premise is that your program is written in. Net.

Mono-service run-time parameters how to configure it?

Command format: mono-service [options] Program.exe

-d:directoryuse This option to specify the working directory for the service. The default is the current directory.

-l:lockfilespecifies the file to use for locking, the default is a filename constructed in/tmp based on the name of the P Rogram that hosts the service.

-m:messagename to show in the syslog.

-n:nameuse this to specify the service is launched (if the program contains more than one service). The default is to run the first defined service.

--debug:use this option to prevent Mono-service from redirecting stdin and stdout, and prevent the program to being sent to th E background. Equivalent to

--no-daemon:use this option to prevent Mono-service from redirecting stdin and stdout and prevent the program to be sent T o the background. Equivalent to--debug.

Example: Mono-service-l:/root/service-lock MyService.exe

Control Service (The difference between these kinds of operations, please refer to the use of Windows, here I do not explain too much):

Pause: kill-usr1 ' cat <lock file> '

Continue: KILL-USR2 ' cat <lock file> '

Stop: Kill ' cat <lock file> '

Note: Use mono-service to run services, the 1.0 assemblies and use Mono-service2 to run services th At use the 2.0 assemblies.

Mono-service can run assemblies for. NET 1.0, and Mono-service2 can run assemblies for. NET 2.0.

Here's another way:http://www.cnblogs.com/sjhrun2001/archive/2009/03/10/1408264.html

How to use mono to migrate. NET Windows service programs to Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.