3

I need the service to automatically start upon boot, it does not require console access for a start. Ofcause it would be nice to be able to produce some output for logging/debugging/stats. But for now, I just need a "TCP listener" that runs in the background, written in C#/mono.

Anyone in here able to show me how you install a service in Debian?

So this program isnt visible, its just like a "daemon" or cron perhaps. Cant figure out where to put it and how to initiate it.

BerggreenDK
  • 364
  • 1
  • 3
  • 14

3 Answers3

6

Create an init.d script to run your application

you can run the mono service in linux OS by using the command mono-service [options] program.exe call this from an init.d sript

Check this man page for more details about running mono service on linux http://linux.die.net/man/1/mono-service

Arun Kumar K S
  • 303
  • 1
  • 3
  • 11
3

If you don't want to write a debian style sysv init script (see /etc/init.d/README), you can just append a line to /etc/rc.local, eg:

/full/path/to/myprogram &

The full path is necessary as $PATH may not be properly set for rc.local when it is run at boot (but it will be for "myprogram").

The & just backgrounds the process, allowing rc.local to continue and exit. "myprogram" is now running owned by root. That may be desirable if you want to open a low number privileged (server) port at start-up; for security the process should subsequently switch (effective) user id (euid/uid).

If you don't need root privileges at all:

/bin/su [user] -c /full/path/to/myprogram &
goldilocks
  • 60,325
  • 17
  • 117
  • 234
1

you can create init.d script and use start-stop-daemon together with nohup to start your app in the background. Here is an example with kestrel web server (which is eventually run with mono). Just change \"$DNXRUNTIME\" kestrel > \"$LOGFILE\" to your command line.

druss
  • 141
  • 2