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.

2
  • cron is a daemon ;)
    – goldilocks
    Feb 27, 2013 at 17:35
  • How did you get on with this? What did you end up doing?
    – Madivad
    Apr 12, 2019 at 12:12

3 Answers 3

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

1
  • cool will try to check that out Feb 27, 2013 at 23:15
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 &
1
  • aha! interesting too! going to check tomorrow too. Feb 27, 2013 at 23:16
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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