10

I'd like to use my Pi as a home thermostat, with the control loop running in a python script. I want to run it as a daemon on raspbian (debian) at startup.

There's an example bash script in /etc/init.d/skeleton, but it seems unpythonic to mash bash and python together. There are python modules and deb packages that can help with start/stop/alert command processing:

Has anyone had success with a particular approach for daemonizing a "real-time" feedback control loop on the Pi?

hobs
  • 203
  • 1
  • 2
  • 6

2 Answers2

6

I have done this on several projects. https://bitbucket.org/dnetman99/raspberrypiprojects if you look at the gpsdpiTracker, the trackerServer.py uses the daemon class to daemonize the script. I then just use restartd to watch if it stops and restarts it, which also means it will start it after boot as well. I also have used the skeleton file for start, stop daemon, but is not necessary if you use this method.

restartd = sudo apt-get install restartd
alecxe
  • 55
  • 10
Robert
  • 271
  • 1
  • 1
2

Look at the way we daemonize in the client pybit-client.

https://github.com/nicholasdavidson/pybit

That was designed to run as a daemon on small ARM boxes 24/7.

Handles logging, signal handling, start/stop scripts etc...

James Bennet
  • 291
  • 1
  • 2