1

I've written a service in C#.

It runs fine on Windows as a service. And I can also get it to run once on Raspberry pi using the command:

mono-service MyService.exe

However, I would like to control the service - i.e. run it as a daemon.

Currently the only way I know how to stop the service is to use the 'ps' command to get the mono process id number and then it using 'kill -9 ' to kill the process.

However doing so has the unfortunate conseqence that I am unable to start the service again? And, so far the only way I've managed to get it to start again is to first reboot.

I understand that the right way to go about this is to start the service like this instead:

mono-service -l:/root/MyService.lock MyService.exe

With -l:MyService.lock creating a file holding the process id of the MyService.exe service so that I can kill that pid rather than the pid for mono.

However, when I do this the service does not start at all and no Myservice.Lock file is created. Adding sudo makes no difference, so I don't think it is a permission issue - but I don't know as my Linux skills are limited.

I'm using all the latest version of software and running this on a Raspberry Pi B+.

I'm stuck here. Any suggestions are very welcome. Thank you.

1iveowl
  • 1,622
  • 1
  • 18
  • 31
  • Did you try with `--debug` to see if there are any clues? (BTW, lock files usually go under /var/run) – mtmk Oct 14 '14 at 10:00
  • Not my area but you might get some clues from [this post on the Raspberry Pi forum](http://raspberrypi.stackexchange.com/questions/5148/how-do-i-run-a-background-service-written-in-mono). – groverboy Oct 14 '14 at 11:08
  • @MaxwellTroyMiltonKing Thanks for the comments. I've been travelling so unable to test before now. I tried with /var/run still no luck. Also, the adding --debug reveals nothing. In fact nothing is reported on the console the when trying mono-service -l:/var/run/MyService.lock --debug MyService.exe – 1iveowl Oct 18 '14 at 08:39
  • @groverboy Thanks for the tip. I've done just that. – 1iveowl Oct 18 '14 at 08:43
  • @JasperHedegaardBojsen you're welcome. I have a R-Pi somewhere too. I wouldn't mind trying it out. Do you mind creating a simplest possible code base that reproduces the issue and put it somewhere public? – mtmk Oct 18 '14 at 23:47
  • @MaxwellTroyMiltonKing Thanks. Try and take a look at this simple version. It runs fine under Windows. It doesn't really do anything. But the challenge is the same in regards to not being able to start it with the "mono-service -l:" parameter. https://github.com/jasperhb/MonoService1 – 1iveowl Oct 19 '14 at 18:15

0 Answers0