openenergymonitor / emonpi

Raspberry Pi Based Energy Monitor. Hardware, Firmware & related software for the PI.
https://guide.openenergymonitor.org/setup
270 stars 113 forks source link

Python systemd servicerunner #67

Closed greeebs closed 6 years ago

greeebs commented 6 years ago

Updates as per the discussion in PR #66

borpin commented 6 years ago

I have just noticed there is a version of the service-runner file actually in the emoncms/backup repo.

greeebs commented 6 years ago

I guess its a question for @glynhudson where this should live then. Maybe once he merges it here, we can just apply the same change to the other repo?

It seems error-prone to have the same "service" being maintained in two places though.

glynhudson commented 6 years ago

Sorry for the delay getting back.

Thanks so much for making these changes. Much appreciated. I've just tested and leave a comment regarding the location of the systemd service file: https://github.com/openenergymonitor/emonpi/pull/67/files#r218467700

Yes, I'm open to moving this new improved service runner to the Emoncms core scrips folder

greeebs commented 6 years ago

Thanks @glynhudson, I've responded to those comments above, I wondered if you'd seen this other comment https://github.com/openenergymonitor/emonpi/pull/66#issuecomment-416422585 I added to the other PR?

borpin commented 6 years ago

On location, I looked at this previously https://community.openenergymonitor.org/t/mosquitto-startup-issues/7386 although I do realise this is not the same situation (i.e. it has not previously been installed).

... unit files for systemd can be placed in one of 3 places and each has a different precedence. Files in /etc followed by /run followed by /lib are used in that order.... Therefore, by putting this replacement service file in /etc/systemd/system, systemd will use that over the stock file in /lib/systemd/system/

I used this reference and the man page.

One other thought, have you tried it without the hyphen? Systemd does some odd things with hyphenated service file names.

greeebs commented 6 years ago

One other thought, have you tried it without the hyphen? Systemd does some odd things with hyphenated service file names. Thanks for the thought, I've just tried that on jessie and it made no difference

I've also tried linking it (with the hyphen) into /etc/systemd/system and that gave me the same errors though... Looks like it needs more investigation on jessie based systems. I'll look into that some more.

glynhudson commented 6 years ago

Sure, I'm happy to go with /lib/systemd/system this should work on all systems.

Thanks @glynhudson, I've responded to those comments above, I wondered if you'd seen this other comment #66 (comment) I added to the other PR?

Sorry I missed this. With regard to touch the logfile this is not required as long as the logfiles is created on a successful run. It's best to remove it.

With regard to moving the service runner to the scripts folder emoncms core repo there are two options:

  1. I could move it over manually closing this PR

  2. You close this PR and open another PR on the emoncms core putting the service runner and unit file into the scripts folder and adding setup instructions to the script readme.

Obviously (2.) requires more action from you but I think it's preferable since you will then get credited with the contribution to the Emoncms core and it will be clearer where the addition came from. In the PR to Emoncms core you could reference these discussions on the emonPi PR.

Thanks again for you help.

borpin commented 6 years ago

Could I suggest that instead of using the scripts folder we create a services folder so any services created (and I am thinking of mqtt here) would go into it?

Maybe even a sub folder by service to keep the service file and the script together?

greeebs commented 6 years ago

Thanks @glynhudson, I'll close this PR (can you close #66 too?) and open a new one in the emoncms repo. It might take a few days as I want to get to the bottom of the jessie systemd issue first.

I'll summarise the discussion points that are still open from here and #66 when I open the new one.