0

I have a TCP server written in C# which I will run on my server. I've tested the application running on the server and client side and it all works great! I'm using mono on my Linux server to run the Server.exe application. I've been experimenting with both Upstart and Shell scripts to get the Server.exe application to run in the background at start up. None of these have worked.

Here is the Shell Script I tried:

#!/bin/sh

/usr/bin/mono Server.exe "$@" &

I then edited the rc.local file found in the /etc directory and added this line:

/usr/local/bin/ClipCloud/start.sh &

Am I missing something here as I can't seem to get it working. It seems to start and then terminate the process straight away. When I start the Server.exe application from terminal by just typing

mono /usr/local/bin/ClipCloud/Server.exe

it works fine and will continue to run until I close the terminal window or type "exit"

I will be happy to share anything I can to help.

5
  • What about nohup /full/path/to/mono /full/path/to/server.exe & ? From now i cannot understand why you use "$@" in your script and not from the terminal
    – krisFR
    Apr 13, 2014 at 1:38
  • I did try this with no luck... Any other ideas? Apr 13, 2014 at 1:49
  • You could try the mono-service command 1) raspberrypi.stackexchange.com/questions/5148/… 2) stackoverflow.com/questions/1221110/…
    – krisFR
    Apr 13, 2014 at 1:59
  • in the same way you try to run manually mono /usr/local/bin/ClipCloud/Server.exe and it works, have you tried running your shell script manually too?
    – knocte
    Apr 13, 2014 at 3:01
  • Yes I've tried running the script manually and nothing seems to happen. I still can't connect from my clients. Apr 13, 2014 at 13:46

1 Answer 1

1

Me too was having this problem. I am now able to run my mono c# app on start up with the help of: http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html

In the "start" section of file (as specified in the above link), do the following: 1. change directory to the folder of your c# app: cd /home/pi/myApp 2. in the next line, add full path of "mono" AND full path of your c# app. For example: /usr/bin/mono /home/pi/myApp/myApp.exe

in the "stop" section, I am not sure how to stop the exact "myApp.exe"; but i stopped the "mono" by giving command:

killall mono

(in effect, the myApp.exe... but if you are running more than one c# apps..please test it.)

Notes

  1. make sure your c# app don't asks for user input...otherwise it will hang
  2. Don't forget to run sudo update-rc.d NameOfYourScript defaults :)
  3. test the script by running "start" and "stop" commands (as specified in the above given link) before you restart your machine.
  4. ALL comment lines in the script is a must. Otherwise you won't be able add it to start up list.

All the best! :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .