Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am very new to Linux and I am currently switching my server from Windows to Centos 6.3. I have written a small UDP server. UDP server was written in C# and now I adopted it to work with Linux using Mono. It is working fine, when I run it this way:

/opt/mono/bin/mono /root/MySoft/UDPServer.exe "$@"

How do I run it automatically--when computer stats? (in windows terms: windows-service)

I tried creating a launcher file and putting it to /etc/init.d but it did not work

share|improve this question
    
What does your init script look like, then? And what does "did not work" mean? –  Michael Hampton Feb 27 '13 at 3:20
    
I created new file with extention .sh and added text: /opt/mono/bin/mono /root/MySoft/UDPServer.exe "$@" –  Andrew Feb 27 '13 at 3:52
    
Does not work means that application does not start; when I send test packets to this app, it is not up and running. When I actually go via Interface to System -> Preferences -> Startup Applications, and add my application there, it works. But it only start working when user is logged in. But I need my program to run when OS starts. –  Andrew Feb 27 '13 at 4:07
add comment

2 Answers

My goto solution for things like this is to install and use supervisord.

Supervisord is a python process supervisor that is very simple to install from your distro's package repo, and simple to configure. You just add a simple config file for your executable and supervisor takes care of starting it up, capturing output, and (optionally) re-starting it if the process fails.

An example config would look like this:

[program:udp_server]
user = <username>
command = /opt/mono/bin/mono /root/MySoft/UDPServer.exe "$@"
stdout_logfile = /var/log/udp_server-stdout.log
stdout_logfile_maxbytes = 10MB
stdout_logfile_backups = 5
stderr_logfile = /var/log/udp_server-stderr.log
stderr_logfile_maxbytes = 10MB
stderr_logfile_backups = 5
share|improve this answer
add comment

Also, this solution worked:

I added my line of text /opt/mono/bin/mono /root/MySoft/UDPServer.exe "$@" & to /etc/rc.d/rc.local

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.