How to troubleshoot services in Rapsberry Pi 3B

39 views Asked by At

I have never done a service before in linux perse, but I been trying to make a service using a Pi.

I used 2 different approaches to create a service. The first approach was using the systemctl using as base the code posted near the end of https://ubuntuforums.org/showthread.php?t=2318279. In my case the ExecStart looks like follow: ExecStart=/home/pi/berryconda2/bin/python /home/pi/Documents/MyCode.py When I start this service using sudo systemctl start MyCode.service it appears as active and running until I execute a another that live in my PC and not in the Pi (they communicate with each other), then I get

  • (code=exited, status=2)
  • Unit entered failed state.
  • Failed with result 'exit-code'.

If I run MyCode.py using my default python interpreter my code work, but I want the pi to run the since boot and continue to run it until I turn it off.

Now for my second approach I utilize the steps describe here http://blog.scphillips.com/posts/2013/07/getting-a-python-script-to-run-in-the-background-as-a-service-on-boot/. At the end when I run my .sh, I get

  • active (exited)
  • (code=exited,status=0/SUCCESS).

As describe in the later link, I run start-stop-daemon --start --pidfile /var/run/MyCode_service.pid --make-pidfile --user root --startas /home/pi/Documents/MyCode.py -- --log /var/log/MyCode_service.log and it work. I'm not sure how to properly debug this services. I have look at https://freedesktop.org/software/systemd/man/systemd.exec.html#id-1.20.8 and http://manpages.ubuntu.com/manpages/cosmic/en/man8/start-stop-daemon.8.html. But I quiet haven't figure it out yet. Can someone point me in the right direction or know of any other building blocks for making a service? or at least trouble shoot it?

0

There are 0 answers