V9.9.0: Migrating to the new systemd+python service-runner

Migrating to the new systemd+python service-runner:
As the name implies, this requires both systemd and python to be installed and configured on your system. Testing was done with python 2.7 but there shouldn’t be any python 3 breaking code in there. systemd is installed by default on Raspbian jessie (and later) as a replacement for the SysV init system to control the startup and shutdown of the operating system (Wkipedia systemd).

To migrate your system from the cron initiated, bash based service-runner requires a few manual steps:

Install the new service-runner systemd service following the instructions in the downloaded file emoncms/scripts/service/install-service-runner-update.md (also in github)

Disable the crontab that runs the existing bash script. The crontab entry looks like this:

* * * * * /home/pi/emonpi/service-runner >> /var/log/service-runner.log 2>&1

Either delete the entry completely or add a # as the first character to “comment it out”. On the emonSD image, this will be in the pi user’s crontab which can be edited by running the following from an ssh session as the user pi:

rpi-rw
crontab -e

which should look like this:

pi@emonpi(ro):~$ rpi-rw
Filesystem is unlocked - Write access
type ' rpi-ro ' to lock
pi@emonpi(rw):~$ crontab -e
crontab: installing new crontab

If you don’t see the crontab: installing new crontab line, run crontab -e again and make sure you save the file (with the default name if prompted)

Finally check the emoncms update script to ensure it didn’t re-add the crontab entry.
The latest master branch of GitHub - openenergymonitor/emonpi: Raspberry Pi Based Energy Monitor. Hardware, Firmware & related software for the PI. has removed the necessary lines, which you can see here:
don't add service runner manually or run update during factory reset · openenergymonitor/emonpi@964545c · GitHub (specifically the removed lines 46 to 69)

4 Likes

Thanks @Greebo that’s a good guide :+1: