Community
OpenEnergyMonitor

Community

EmonHub Failing After Update

Not sure what went wrong - run a full update from the admin page on my stock emonPi (latest SD build), and now EmonHub process won’t start. Have tried restarting through EmonHub page and via cmd line restart. Have tried a couple of reboots and using the update button in the EmonHub page. No dice…

-- Logs begin at Fri 2016-11-04 04:16:43 AEDT, end at Sat 2019-07-13 16:35:01 AEST. --
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Main process exited, code=exited, status=203/EXEC
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Unit entered failed state.
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Failed with result 'exit-code'.
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Service hold-off time over, scheduling restart.
Jul 13 16:33:25 emonpi systemd[1]: Stopped emonHub service description.
Jul 13 16:33:25 emonpi systemd[1]: Starting emonHub service description...
Jul 13 16:33:25 emonpi systemd[1]: Started emonHub service description.
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Main process exited, code=exited, status=203/EXEC
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Unit entered failed state.
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Failed with result 'exit-code'.
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Service hold-off time over, scheduling restart.
Jul 13 16:33:25 emonpi systemd[1]: Stopped emonHub service description.
Jul 13 16:33:25 emonpi systemd[1]: Starting emonHub service description...
Jul 13 16:33:25 emonpi systemd[1]: Started emonHub service description.
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Main process exited, code=exited, status=203/EXEC
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Unit entered failed state.
Jul 13 16:33:25 emonpi systemd[1]: emonhub.service: Failed with result 'exit-code'.

A snip of the Pi update logs for emonhub show:

Start emonhub update script:
-------------------------------------------------------------
emonHub update started
-------------------------------------------------------------
- usr directory: /home/pi
git pull /home/pi/emonhub
* emon-pi
On branch emon-pi
Your branch is up-to-date with 'origin/emon-pi'.
nothing to commit, working tree clean
Already up-to-date.
emonhub.service already installed

Running emonhub automatic node addition script
[[5]]
Node 5 already present
[[6]]
Node 6 already present
[[7]]
Node 7 already present
[[8]]
Node 8 already present
[[9]]
Node 9 already present
[[10]]
Node 10 already present
[[11]]
Node 11 already present
[[12]]
Node 12 already present
[[13]]
Node 13 already present
[[14]]
Node 14 already present
[[19]]
Node 19 already present
[[20]]
Node 20 already present
[[21]]
Node 21 already present
[[22]]
Node 22 already present
[[23]]
Node 23 already present
[[24]]
Node 24 already present
[[25]]
Node 25 already present
[[26]]
Node 26 already present

Update process finished with a process start issue also:

-------------------------------------------------------------
emonPi update done: Sat 13 Jul 16:33:30 AEST 2019
-------------------------------------------------------------
restarting service-runner
service-runner: no process found

Hi, do you have SSH access to the pi?

If so, could you post the output from this command?

sudo systemctl cat emonhub

and also from

ls -la /usr/{local/bin,share}/emonhub

a “status=203/EXEC” is apparently a “no such file or directory” fault so something must of tripped up with the paths or file locations during the update.

Do you recall what you were updating from? ie is this regularly updated or has it been a while? Also what image version is it? (found on the admin page or a “emonsd???” file on the boot partition.

[edit] Can you also post the output from

sudo systemctl status emonhub

[edit2]

That warning is always there even on a good update, it has been pointed out many times before but hasn’t yet been dealt with, so you can ignore that AFAIK, although the issue with getting into the habit of ignoring a false warning is that one day it might just be accurate.

I actually just updated the service file to point it at (what I thought) was the correct config path. I assume a save and reboot would work but no change…

It was updated only a 2-3 weeks ago and pretty regular.
emonpiRelease: emonSD-30Oct18

[email protected]:~ $ sudo systemctl cat emonhub
# /home/pi/emonhub/service/emonhub.service
[Unit]
Description=emonHub service description
DefaultDependencies=no
Before=shutdown.target
Conflicts=shutdown.target
Requires=local-fs.target
After=sysinit.target syslog.target local-fs.target

[Service]
User=emonhub
PIDFile=/var/run/emonhub.pid
ExecStart=/usr/local/bin/emonhub/emonhub.py --config-file=/home/pi/data/emonhub.conf --logfil
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/log/emonhub/
ExecStartPre=/bin/chgrp -R emonhub /var/log/emonhub/
ExecStartPre=/bin/chmod 775 /var/log/emonhub/
Type=simple
Restart=always

[Install]
WantedBy=multi-user.target

Previously it was pointing to:

ExecStart=/usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhub.log

Directory:

[email protected]:~ $ ls -la /usr/{local/bin,share}/emonhub
ls: cannot access '/usr/local/bin/emonhub': No such file or directory
lrwxrwxrwx 1 root root 20 Aug  2  2018 /usr/share/emonhub -> /home/pi/emonhub/src

It would seem that this part of the update was not succesful

and given the old symlink is still there, this bit must of failed too

which in turn raises questions about where exactly this fell over and what has or hasn’t been updated, and also why there was no indication of an issue.

If it is just the symlink then you should be able to get back up and running by just adding the link manually and restarting the service

sudo ln -sf /home/pi/emonhub/src /usr/local/bin/emonhub
sudo systemctl start emonhub
1 Like

This fixed it. Thanks @pb66 but yes, not sure why but never any issues with previous releases… I’ve also had no Backup module since going to 10.x despite trying update, etc.

Error: missing backup config.cfg

I suspect it was actually previously pointing at /usr/share/emonhub/emonhub.py . . . as that was the original path and the original symlink is still there.

I had also thought a decision had been made to use an absolute path of

/usr/bin/python /usr/local/bin/emonhub/emonhub.py

but I see no evidence of that in the updates or repos.

That’s not something I’m familiar with I’m afraid.

[edit]

I had a brief look at the updater and assuming (never a good idea) that this bit was successful

then this bit must of failed

but that’s mostly a guess on my part. Some serious rolling up of the sleeves would be needed for me to delve any deeper into that code.

Bottom line, I think is to find where your emoncms modules are located (ie did they get moved successfully) and then check that the default.config.cfg file was duplicated and then edited with all the right paths, I guess.

1 Like

If your suggestion to create the symlink manually @pb66’s fixed the issue, then re-running the update process should do the same, given the command is also in the update script, is that right? It sounds like something failed to update (perhaps the emonpi repo?) earlier in the update causing further failures down the line.

I’ve seen this happen in the past where either there are local changes or there’s a temporary loss of internet connection. The update script needs quite a bit more work really to cater for both of these, which would be good to do.

@Tockley did you try running the update process more than once?

I did - I ran it twice. I think I might have saved the update logs which could point to the issue, I will have a look on my home machine later today.

Alas, I have lost the original logs from update 1 and 2.

1 Like

Thanks for checking

Hi,

I had same problem, but after /usr/local/bin/emonhub link fixed, then I also had problem with missing config file /etc/emonhub/emonhub.conf

So I created missing directory and link in it:

sudo mkdir /etc/emonhub
sudo ln -sf /home/pi/data/emonhub.conf /etc/emonhub/emonhub.conf

Not sure it is the right to do, or just edit emonhub.service in /home/pi/emonhub/service ?
But seems emonhub.service updated , so maybe those link is missing too.

 systemctl cat emonhub
# /home/pi/emonhub/service/emonhub.service
[Unit]
Description=emonHub service description
DefaultDependencies=no
Before=shutdown.target
Conflicts=shutdown.target
Requires=local-fs.target
After=sysinit.target syslog.target local-fs.target

[Service]
User=emonhub
PIDFile=/var/run/emonhub.pid
ExecStart=/usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhub.l
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/log/emonhub/
ExecStartPre=/bin/chgrp -R emonhub /var/log/emonhub/
ExecStartPre=/bin/chmod 775 /var/log/emonhub/
Type=simple
Restart=always

[Install]
WantedBy=multi-user.target

BR
Dimitar

Good to hear you sorted your problem out, it is better to create the directory and symlink than edit the service unit so that your setup continues to be in line with the stock OEM image. Had you edited the service unit, it would have most likely blocked future updates to emonhub via the updater as git will abort pulling in updates if it detects local changes in the files to be updated.

What you’ve done is exactly what should of happened in the update, just like Sam’s update, your’s has not completed succesfully either, in this case it appears to have skipped/missed these 2 parts

The symlink obviously can’t be created if the directory doesn’t exist.

It’s not clear to me why the updater appears to pick and choose which bits to run, but looking back at the update log snippet in the opening post, it seems there was no problem with the git pull and then it jumps straight to “emonhub.service already installed” and then “Running emonhub automatic node addition script”. These are the last 2 items in the emonhub update script and we should have seen “Creating emonhub logfile” and “Symlinking emonhub.conf to /etc/emonhub/emonhub.conf” echod to the log regardless of whether it actually performed those operations or not due to the fact they are located outside the conditional tests for executing those operations.

Thanks for letting us know Dimitar.

Hi,
just updated to the latest version and ran into what seems to be the same problem: Emonhub Failed.

I’m not very familiar with the technical stuff, and I don’t know where I need to enter the above two sudo commands. In SSH on the command line?

Many thanks for your help.

UPDATE:
I entered the quoted two sudo commands on SSH command line.
First sudo cmd finished, the second failed with:

:Job for emonhub.service failed. See systemctl status emonhub.service and journalctl -xn for details.

Status of emonhub.service:

● emonhub.service - LSB: Start/stop emonHub
   Loaded: loaded (/etc/init.d/emonhub)
   Active: failed (Result: exit-code) since Tue 2019-07-23 16:06:01 NZST; 10s ago
  Process: 8168 ExecStart=/etc/init.d/emonhub start (code=exited, status=1/FAILURE)

and: journalctl -xn:

No journal files were found.

When I tried to update EMONHUB for the second time, the log shows:

Update Log

Starting update via service-runner-update.sh (v2.0) >
Filesystem is unlocked - Write access
type ’ rpi-ro ’ to lock

  • emonSD version: emonSD-07Nov16
    emonSD base image check passed…continue update
    git pull /home/pi/emonpi
  • master
    wifiap
    On branch master
    Your branch is up-to-date with ‘origin/master’.
    Untracked files:
    (use “git add …” to include in what will be committed)

    1
    restart.sh

nothing added to commit but untracked files present (use “git add” to track)
Already up-to-date.

Main Update Script

Date: Tue 23 Jul 16:41:31 NZST 2019
EUID: 1000
usrdir: /home/pi
type: emonhub
firmware: emonpi
Checking environment:

  • pi user found

EUID: 1000
Hardware detected: EmonPi
Stopping emonPiLCD service
Display update message on LCD
I2C LCD DETECTED Ox3f
Start emonhub update script:

emonHub update started

  • usr directory: /home/pi
    git pull /home/pi/emonhub
    K0den-wibeee_interface
  • emon-pi
    hmm01i-syslogging
    On branch emon-pi
    Your branch is behind ‘origin/emon-pi’ by 147 commits, and can be fast-forwarded.
    (use “git pull” to update your local branch)
    Changes not staged for commit:
    (use “git add …” to update what will be committed)
    (use “git checkout – …” to discard changes in working directory)

    modified: src/emonhub.py

Untracked files:
(use “git add …” to include in what will be committed)

src/src

no changes added to commit (use “git add” and/or “git commit -a”)
error: Your local changes to the following files would be overwritten by merge:
src/emonhub.py
Please, commit your changes or stash them before you can merge.
Aborting
Updating 756a33d…ee1f537
Creating emonhub logfile
Symlinking emonhub.conf to /etc/emonhub/emonhub.conf
Job for emonhub.service failed. See ‘systemctl status emonhub.service’ and ‘journalctl -xn’ for details.

Running emonhub automatic node addition script
EUID: 1000
[[5]]
Node 5 already present
[[6]]
Node 6 already present
[[7]]
Node 7 already present
[[8]]
Node 8 already present
[[9]]
Node 9 already present
[[10]]
Node 10 already present
[[11]]
Node 11 already present
[[12]]
Node 12 already present
[[13]]
Node 13 already present
[[14]]
Node 14 already present
[[19]]
Node 19 already present
[[20]]
Node 20 already present
[[21]]
Node 21 already present
[[22]]
Node 22 already present
[[23]]
Node 23 already present
[[24]]
Node 24 already present
[[25]]
Node 25 already present
[[26]]
Node 26 already present

Starting emonPi LCD service…

Filesystem is locked - Read Only access
type ’ rpi-rw ’ to unlock


emonPi update done: Tue 23 Jul 16:41:41 NZST 2019


I also cannot make sense of the line:

error: Your local changes to the following files would be overwritten by merge:
src/emonhub.py

As far as I know there are no local changes, the Emonpi is stock standard, except for having to remove the # comment lines in the backup.conf file earlier this year after causing PHP errors for backups after updating to 10.0.2.

I am a bit lost now.
BTW, I’m on Nov16 SD card, but 10.1.2 emoncms. Before the update I was on 10.0.2.

I have yet to find git wrong when reporting local changes, so whilst i can’t say it’s not possible I do think it’s unlikely (at this stage). If you go to the emonhub folder you can ask git what the changes are.

cd /home/pi/emonhub
git diff src/emonhub.py

This may jog the memory or at least tell you what you might lose if we force an update.

It looks like it hasn’t updated for quite some time as there are 147 commits outstanding, I don’t know how frequently you run an update, but it looks like emonhub hasn’t succesfully updated since mid 2017’ish, this may just be the first time the failed (ie partial) update has caused it to stop running.

There is also a second local change reported in that there is apparently an untracked src folder inside the original src folder, couls you run

ls -la src/src

whilst you are still in the emonhub folder and post what you find.

I’m just heading out soon so I may not be around til later. If you can run these couple of commands, it will tell us the status of the symlinks to see if you have actually had a similar issue to the cases above. So far it just looks like the git pull failed due to the local changes, there’s nothing (yet) to suggest any of the symlinking has failed.

ls -la /usr/{local/bin,share}/emonhub
ls -la /etc/{init.d/,}emonhub
systemctl cat emonhub.service

If you are happy to lose the local changes to src/emonhub.py, you can force a update with (from within the emonhub folder again)

git checkout -f -b emon-pi

It may also be worth running these 2 commands for good measure

sudo systemctl daemon-reload
sudo systemctl --now enable emonhub.service

assuming there are no other errors, you could run the update again to confirm all is ticketty-boo. If the above command doesn’t work, there is a longer “hard reset” procedure we can try, but I don’t know those commands off hand, I tend to use the above without any issue.

Sorry for the info overload, but I’m trying to give you everything you might need to get it running today rather than wait for me, please post any errors or results etc, if you would rather wait and go through step bey step we can.

Thanks @pb66 for your help.

The git diff produces nothing that I would know or remember: (or is it a fix suggested by your team many years ago with some issue we had back then?)

[email protected](ro):emonhub$ git diff src/emonhub.py
diff --git a/src/emonhub.py b/src/emonhub.py
index aee21c0…84c4271 100755
— a/src/emonhub.py
+++ b/src/emonhub.py
@@ -138,6 +138,7 @@ class EmonHub(object):
if not I.isAlive():
#I.start()
self._log.warning(I.name + " thread is dead") # had to be restarted")
self._exit = True
# Sleep until next iteration
time.sleep(0.2)

I have updated EMONCMS last in June 2019, to version 10.0.2, but not since then. Are you saying when I updated that emonhub was left behind with a much older version? Without reading every line of the update logs, I was not aware that anything ever failed. Perhaps my fault for not reading all the lines …?

When I run ls -la src/src I get:

[email protected](ro):emonhub$ ls -la src/src
lrwxrwxrwx 1 root root 20 Jul 23 16:41 src/src -> /home/pi/emonhub/src

Unfortunately that means nothing to me either.

As far as the remaining commands go that you gave me, where does the forced update start? When I tried the following next of your commands, it failed with

[email protected](ro):emonhub$ ls -la /usr/{local/bin,share}/emonhub
ls: cannot access /usr/share/emonhub: No such file or directory
lrwxrwxrwx 1 root staff 20 Jul 23 15:28 /usr/local/bin/emonhub -> /home/pi/emonhub/src

With my lack of knowledge I think I better stop here and await your advice. I really have no idea what I would be overwriting.

Looks like I should have started a new topic - the cause of this seems unrelated to the original issue. Apologies.

Done some searching, and found the ‘local’ change below was related to a fix in Jun 2017, due to Emonpi requiring periodic restarting. See EmonPi needs periodic restarting for details.
I think this is no longer needed, right?

[email protected](ro):emonhub$ git diff src/emonhub.py
diff --git a/src/emonhub.py b/src/emonhub.py
index aee21c0…84c4271 100755
— a/src/emonhub.py
+++ b/src/emonhub.py
@@ -138,6 +138,7 @@ class EmonHub(object):
if not I.isAlive():
#I.start()
self._log.warning(I.name + " thread is dead") # had to be restarted")
self._exit = True
`# Sleep until next iteration
time.sleep(0.2)

In fact, the watchdog for this fix is still in my crontab.

 * * * * * /home/pi/watchdog.sh >> /home/pi/data/watchdog.log 2>&1

Is it obsolete and safe to remove now? I asked that question in May 2019 but did not get replies:

Seeing that, I thought I can force an update for emonhub without losing anything important. I started with the two ls and the one cat commands:

[email protected](rw):emonhub$ ls -la /usr/{local/bin,share}/emonhub
ls: cannot access /usr/share/emonhub: No such file or directory
lrwxrwxrwx 1 root staff 20 Jul 23 15:28 /usr/local/bin/emonhub -> /home/pi/emonhub/src
 
[email protected](rw):emonhub$ ls -la /etc/{init.d/,}emonhub
lrwxrwxrwx 1 root root   32 Jan 26  2016 /etc/init.d/emonhub -> /home/pi/emonhub/service/emonhub
/etc/emonhub:
total 8
drwxr-xr-x   2 root root 4096 Jul 23 16:41 .
drwxr-xr-x 100 root root 4096 Jul 23 15:39 ..
lrwxrwxrwx   1 root root   26 Jul 23 16:41 emonhub.conf -> /home/pi/data/emonhub.conf

[email protected](rw):emonhub$ systemctl cat emonhub.service
# /run/systemd/generator.late/emonhub.service
# Automatically generated by systemd-sysv-generator

[Unit]
SourcePath=/etc/init.d/emonhub
Description=LSB: Start/stop emonHub
Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target
After=remote-fs.target systemd-journald-dev-log.socket
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
SysVStartPriority=3
ExecStart=/etc/init.d/emonhub start
ExecStop=/etc/init.d/emonhub stop
[email protected](rw):emonhub$

Then I tried the forced update of emonhub: git checkout -f -b emon-pi, but it fails with:

[email protected](rw):emonhub$ git checkout -f -b emon-pi
fatal: A branch named 'emon-pi' already exists.

Hmm, what should I do next? Many thanks for your help.

Not a problem, it is related though. We do not have all the info on the previous 2 occurrences, but from your last reply it would seem the update failed to complete (aside from the failed git pull), possibly or even probably due to the git pull failing because of local changes. The update script needs to handle these situations and either complete or back out so that a working system is maintained, and more importantly it should clearly tell the user there is a issue. Perhaps a final status at the end of the update as a minimum, a user should not need to read the whole log line by line to know if the update was done successfully or not.

Correct, glad you worked out the history, local changes are usually there for a reason and blindly resetting isn’t always without consequence. But here you can indeed safely reset and get rid of the line in crontab.

The first command checked both the original and the new locations for the link to emonhub/src, the result tells us nothing was found at the original location and a link to the emonhub/src was found at the new location, so that part seems to have succeeded ok.

The second command tested for 3 things, whether the old original int.d service unit had been removed, whether the etc/emonhub folder exists and whether a link to the emonhub.conf on the writable data partition exists. The latter 2 passed. But the init.d service script seems to still exist, it should of been deleted.

This is further confirmed but the last command as the systemd service unit’s source path is /etc/init.d/emonhub.

My apologies, that “-b” shouldn’t be there, that creates a new branch, we were trying to reset the existing branch, hence the “already exists” error.

So from within the emonhub folder, try

git checkout -f emon-pi

At this point I would say try doing a full update again. I say this because the init.d script that wasn’t deleted, should have been deleted by a sub-script whilst symlinking reloading, restarting and enabling the new service unit. We do not know where it fell over so running it again may fill in any “missed” parts.

once completed run

sudo system status emonhub.service

to confirm emonhub is running ok, if there are any errors then run these and post results here along with the results of the previous command

sudo systemctl cat emonhub.service
ls -la /{etc,lib}/systemd/system/emonhub.service
ls -la /etc/init.d/emonhub

and we can sort it out manually.

I ran that, and got

[email protected](rw):emonhub$ git checkout -f emon-pi
Already on ‘emon-pi’
Your branch is behind ‘origin/emon-pi’ by 147 commits, and can be fast-forwarded.
(use “git pull” to update your local branch)

Then I accidentally ran a ‘Update EMONHUB’, and when I noticed my mistake a full update from EMONCMS admin page. Emonhub still shows FAILED after that. Got a very long log, which I struggled a bit to include here in a readable format:

Starting update via service-runner-update.sh (v2.0) >
Filesystem is unlocked - Write access
type ’ rpi-ro ’ to lock
- emonSD version: emonSD-07Nov16 emonSD base image check passed...continue update git pull /home/pi/emonpi* master
wifiap
On branch master
Your branch is up-to-date with ‘origin/master’.
Untracked files:
(use “git add …” to include in what will be committed)
1 restart.sh
nothing added to commit but untracked files present (use “git add” to track)
Already up-to-date.
------------------------------------------------------------- Main Update Script-------------------------------------------------------------
Date: Wed 24 Jul 23:18:46 NZST 2019
EUID: 1000
usrdir: /home/pi
type: all
firmware: emonpi
Checking environment:
- pi user found
EUID: 1000
Hardware detected: EmonPi
Stopping emonPiLCD service
Display update message on LCD
I2C LCD DETECTED Ox3f
------------------------------------------------------------- Ign http://dl.bintray.com stable InRelease Get:1 http://dl.bintray.com stable Release.gpg [821 B] Hit http://ppa.launchpad.net xenial InRelease Get:2 http://dl.bintray.com stable Release [6,051 B] Get:3 http://dl.bintray.com stable/main armhf Packages [77.8 kB] Hit http://ppa.launchpad.net xenial/main Sources Hit http://ppa.launchpad.net xenial/main armhf Packages Hit http://ppa.launchpad.net xenial/main Translation-en Get:4 http://repo.mosquitto.org jessie InRelease [11.0 kB] Ign http://dl.bintray.com stable/main Translation-en_GB Hit http://mirrordirector.raspbian.org jessie InRelease Err http://repo.mosquitto.org jessie InRelease
Ign http://dl.bintray.com stable/main Translation-en
Hit http://mirrordirector.raspbian.org jessie/main armhf Packages
Hit http://mirrordirector.raspbian.org jessie/contrib armhf Packages
Hit http://mirrordirector.raspbian.org jessie/non-free armhf Packages
Hit http://mirrordirector.raspbian.org jessie/rpi armhf Packages
Hit http://archive.raspberrypi.org jessie InRelease
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/contrib Translation-en
Ign http://mirrordirector.raspbian.org jessie/main Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/main Translation-en
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/non-free Translation-en
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en_GB
Ign http://mirrordirector.raspbian.org jessie/rpi Translation-en
Hit http://archive.raspberrypi.org jessie/main armhf Packages
Hit http://archive.raspberrypi.org jessie/ui armhf Packages
Ign http://archive.raspberrypi.org jessie/main Translation-en_GB
Ign http://archive.raspberrypi.org jessie/main Translation-en
Ign http://archive.raspberrypi.org jessie/ui Translation-en_GB
Ign http://archive.raspberrypi.org jessie/ui Translation-en
Fetched 84.6 kB in 51s (1,657 B/s)
Reading package lists…
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://repo.mosquitto.org jessie InRelease: The following signatures were invalid: KEYEXPIRED 1515017477 KEYEXPIRED 1515017477 KEYEXPIRED 1515017477
W: Failed to fetch http://repo.mosquitto.org/debian/dists/jessie/InRelease
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists…
Building dependency tree…
Reading state information…
rng-tools is already the newest version.
python-gpiozero is already the newest version.
python-rpi.gpio is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 211 not upgraded.
Requirement already up-to-date: paho-mqtt in /usr/local/lib/python2.7/dist-packages
You are using pip version 9.0.1, however version 19.1.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
------------------------------------------------------------- git pull /home/pi/RFM2Pi* master
On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean
Already up-to-date.
git pull /home/pi/usefulscripts* master
On branch master
Your branch is behind ‘origin/master’ by 45 commits, and can be fast-forwarded.
(use “git pull” to update your local branch)
Changes not staged for commit:
(use “git add …” to update what will be committed)
(use “git checkout – …” to discard changes in working directory)
modified: convertdata/phptimestore_to_phpfina.php modified: process/power_to_kwh.php modified: readme.md
Untracked files:
(use “git add …” to include in what will be committed)
update_emoncms.sh
no changes added to commit (use “git add” and/or “git commit -a”)
error: Your local changes to the following files would be overwritten by merge:
convertdata/phptimestore_to_phpfina.php
process/power_to_kwh.php
readme.md
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
update_emoncms.sh
Please move or remove them before you can merge.
Aborting
Updating 6cf8e48…6d3942c
git pull /home/pi/huawei-hilink-status* master
On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean
error: cannot open .git/FETCH_HEAD: Permission denied
git pull /home/pi/oem_openHab* master
On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean
Already up-to-date.
git pull /home/pi/oem_node-red* master
On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean
Already up-to-date.
-------------------------------------------------------------
EmonPi Firmware Update
------------------------------------------------------------- Start ATmega328 serial upload using avrdude with latest.hex Discrete Sampling avrdude -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:/home/pi/emonpi/firmware/compiled/latest.hex avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude-original: Device signature = 0x1e950f
avrdude-original: NOTE: “flash” memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude-original: erasing chip
avrdude-original: reading input file “/home/pi/emonpi/firmware/compiled/latest.hex”
avrdude-original: input file /home/pi/emonpi/firmware/compiled/latest.hex auto detected as Intel Hex
avrdude-original: writing flash (17886 bytes):
Writing | ################################################## | 100% 2.45s
avrdude-original: 17886 bytes of flash written
avrdude-original: verifying flash memory against /home/pi/emonpi/firmware/compiled/latest.hex:
avrdude-original: load data flash data from input file /home/pi/emonpi/firmware/compiled/latest.hex:
avrdude-original: input file /home/pi/emonpi/firmware/compiled/latest.hex auto detected as Intel Hex
avrdude-original: input file /home/pi/emonpi/firmware/compiled/latest.hex contains 17886 bytes
avrdude-original: reading on-chip flash data:
Reading | ################################################## | 100% 1.83s
avrdude-original: verifying …
avrdude-original: 17886 bytes of flash verified
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
strace: |autoreset: Broken pipe
avrdude-original done. Thank you.
strace: |autoreset: Broken pipe
Start emonhub update script:
------------------------------------------------------------- emonHub update started-------------------------------------------------------------
- usr directory: /home/pi git pull /home/pi/emonhub K0den-wibeee_interface* emon-pi
hmm01i-syslogging
On branch emon-pi
Your branch is up-to-date with ‘origin/emon-pi’.
Untracked files:
(use “git add …” to include in what will be committed)
src/src
nothing added to commit but untracked files present (use “git add” to track)
Already up-to-date.
Creating emonhub logfile
Symlinking emonhub.conf to /etc/emonhub/emonhub.conf
emonhub.service already installed
Running emonhub automatic node addition script [[5]] Node 5 already present [[6]] Node 6 already present [[7]] Node 7 already present [[8]] Node 8 already present [[9]] Node 9 already present [[10]] Node 10 already present [[11]] Node 11 already present [[12]] Node 12 already present [[13]] Node 13 already present [[14]] Node 14 already present [[19]] Node 19 already present [[20]] Node 20 already present [[21]] Node 21 already present [[22]] Node 22 already present [[23]] Node 23 already present [[24]] Node 24 already present [[25]] Node 25 already present [[26]] Node 26 already present
Start emoncms update:
-------------------------------------------------------------
Emoncms update started
Emoncms update script V1.3 (26th March 2019)
-------------------------------------------------------------- usr directory: /home/pi
- emoncms directory: /var/www/emoncms
current settings.php md5: 0e4803a641b7784ed23edf87506ce761
Default settings.php md5: 0e4803a641b7784ed23edf87506ce761
settings.php has NOT been user modifed
Checking status of /var/www/emoncms git repository- git branch: stable
- no local changes- running: git pull origin stable
From https://github.com/emoncms/emoncms * branch stable -> FETCH_HEAD
Already up-to-date.
NEW default settings.php md5: 0e4803a641b7784ed23edf87506ce761 settings.php not updated
------------------------------------------------------------- Updating Emoncms Modules-------------------------------------------------------------
------------------------------------------
Updating /var/www/emoncms/Modules/app module
------------------------------------------- git branch: stable
- git tags: 1.2.0-108-g6e5016a- no local changes
- running: git pull origin stable
From https://github.com/emoncms/app
* branch stable -> FETCH_HEAD Already up-to-date.
------------------------------------------ Updating /var/www/emoncms/Modules/config module------------------------------------------
- git branch: stable- git tags: 1.0.0-63-g1d9238e
- no local changes- running: git pull origin stable
From https://github.com/emoncms/config * branch stable -> FETCH_HEAD
Already up-to-date.
------------------------------------------
Updating /var/www/emoncms/Modules/dashboard module
------------------------------------------- git branch: stable
- git tags: 1.3.1-134-g337df80- no local changes
- running: git pull origin stable
From https://github.com/emoncms/dashboard
* branch stable -> FETCH_HEAD Already up-to-date.
------------------------------------------ Updating /var/www/emoncms/Modules/device module------------------------------------------
- git branch: master- git tags: 1.1.1-50-g7dd5c26
- no local changes- running: git pull origin master
From https://github.com/emoncms/device * branch master -> FETCH_HEAD
Already up-to-date.
------------------------------------------
Updating /var/www/emoncms/Modules/graph module
------------------------------------------- git branch: stable
- git tags: 1.2.1-151-gc7f4ea9- no local changes
- running: git pull origin stable
From https://github.com/emoncms/graph
* branch stable -> FETCH_HEAD Already up-to-date.
------------------------------------------ Updating /var/www/emoncms/Modules/wifi module------------------------------------------
- git branch: stable- git tags: 1.2.0-39-gb67783d
- no local changes- running: git pull origin stable
From https://github.com/emoncms/wifi * branch stable -> FETCH_HEAD
Already up-to-date.
------------------------------------------
Updating postprocess module
------------------------------------------- git branch: emonpi
- git tags: 2.1.0-3-g558173e- no local changes
- running: git pull origin emonpi
Already up-to-date.
Already on ‘emonpi’
Your branch is up-to-date with ‘remotes/origin/emonpi’.
------------------------------------------
Updating sync module------------------------------------------
- git branch: master- git tags: 2.0.1-11-ge7dcf33
- no local changes- running: git pull origin master
Already up-to-date.
Already on 'master' Your branch is up-to-date with 'origin/master'.
------------------------------------------ Updating backup module------------------------------------------
- git branch: stable- git tags: 2.0.0-12-g67a1f1d
- no local changes- running: git pull origin stable
Already up-to-date. Already on 'stable' Your branch is up-to-date with 'origin/stable'.
------------------------------------------ Auto Installation of Emoncms Modules------------------------------------------
- graph module already installed- device module already installed
- postprocess module already installed- sync module already installed
- backup module already installed
www-data : www-data video systemd-journal
------------------------------------------
SERVICES
------------------------------------------ emoncms_mqtt.service already installed feedwriter.service already installed service-runner.service already installed------------------------------------------
Reloading systemctl deamon
Update Emoncms database

Restarting Services…
- sudo systemctl restart feedwriter.service— ActiveState=active —
- sudo systemctl restart emoncms_mqtt.service— ActiveState=active —
- sudo systemctl restart emonhub.service— ActiveState=active —
- sudo /etc/init.d/openhab restart Restarting openhab (via systemctl): openhab.service. openhab.service - Starts and stops the openHAB Home Automation Bus Loaded: loaded (/usr/lib/systemd/system/openhab.service; enabled) Active: active (running) since Wed 2019-07-24 23:21:07 NZST; 88ms ago Docs: http://www.openhab.org Process: 28667 ExecStartPre=/usr/share/openhab/bin/setpermissions.sh (code=exited, status=0/SUCCESS) Main PID: 28715 (openhab.sh) CGroup: /system.slice/openhab.service ├─28715 /bin/sh /usr/share/openhab/bin/openhab.sh -o └─28737 /usr/bin/java -Dlogback.configurationFile=/etc/openhab/logback.xml -Dosgi.clean=true -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Djetty.port=8080 -Dopenhab.configfile=/etc/openhab/configurations/openhab.cfg -Dopenhab.configdir=/etc/openhab/configurations -Dopenhab.logdir=/var/log/openhab -Dsmarthome.userdata=/var/lib/openhab -Djetty.home=/usr/share/openhab -Djetty.port.ssl=8443 -Djetty.config=/etc/openhab/jetty -Djetty.logs=/var/log/openhab -Djetty.rundir=/usr/share/openhab -Dfelix.fileinstall.dir=/usr/share/openhab/addons -Dfelix.fileinstall.filter=.*\.jar -Djava.library.path=/usr/share/openhab/lib -Djava.security.auth.login.config=/etc/openhab/login.conf -Dorg.quartz.properties=/etc/openhab/quartz.properties -Dequinox.ds.block_timeout=240000 -Dequinox.scr.waitTimeOnBlock=60000 -Dfelix.fileinstall.active.level=4 -Djava.awt.headless=true -jar /usr/share/openhab/server/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar -configuration /var/lib/openhab/workspace -data /var/lib/openhab/workspace -console 5555
Jul 24 23:21:07 emonpi setpermissions.sh[28667]: setting owner openhab:openhab recursively for /var/lib/openhab
Jul 24 23:21:07 emonpi setpermissions.sh[28667]: setting permissions and owner openhab:openhab recursively for /var/log/openhab
Jul 24 23:21:07 emonpi setpermissions.sh[28667]: setting permissions and owner openhab:openhab recursively for /etc/openhab/configurations
Jul 24 23:21:07 emonpi setpermissions.sh[28667]: setting permissions and owner openhab:openhab for /usr/share/openhab/webapps/static
Jul 24 23:21:07 emonpi setpermissions.sh[28667]: setting permissions and owner openhab:openhab for /etc/openhab/jetty/etc/keystore
Jul 24 23:21:07 emonpi setpermissions.sh[28667]: setting permissions and owner openhab:openhab for /etc/openhab/configurations/users.cfg
Jul 24 23:21:07 emonpi systemd[1]: Started Starts and stops the openHAB Home Automation Bus.
Symlinking emonpiupdate.log
Installing emoncms logrotate…
Now setting up Logrotate... Backing up old logrotate configuration... Linked to new logrotate configuration... Backing up old logrotate cron job... mv: cannot stat ‘/etc/cron.daily/logrotate’: No such file or directory Linked to new logrotate cron job...
Completed

Completed
Running logrotate...
set log rotate config owner to root
------------------------------------------
Emoncms update script complete
------------------------------------------
Starting emonPi LCD service..
Filesystem is locked - Read Only access
type ’ rpi-rw ’ to unlock
-------------------------------------------------------------
emonPi update done: Wed 24 Jul 23:21:15 NZST 2019
------------------------------------------------------------- restarting service-runner Then I ran sudo systemctl status emonhub.service and got
[email protected](ro):emonhub$ sudo systemctl status emonhub.service
emonhub.service - emonHub service description
Loaded: loaded (/home/pi/emonhub/service/emonhub.service; disabled)
Active: failed (Result: start-limit) since Wed 2019-07-24 23:13:04 NZST; 2min 50s ago
Process: 24955 ExecStart=/usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhub.log (code=exited, status=1/FAILURE)
Process: 24952 ExecStartPre=/bin/chmod 775 /var/log/emonhub/ (code=exited, status=0/SUCCESS)
Process: 24949 ExecStartPre=/bin/chgrp -R emonhub /var/log/emonhub/ (code=exited, status=0/SUCCESS)
Process: 24946 ExecStartPre=/bin/mkdir -p /var/log/emonhub/ (code=exited, status=0/SUCCESS)
Main PID: 24955 (code=exited, status=1/FAILURE)
`
Jul 24 23:13:03 emonpi systemd[1]: Unit emonhub.service entered failed state.
Jul 24 23:13:04 emonpi systemd[1]: emonhub.service holdoff time over, scheduling restart.
Jul 24 23:13:04 emonpi systemd[1]: Stopping emonHub service description…
Jul 24 23:13:04 emonpi systemd[1]: Starting emonHub service description…
Jul 24 23:13:04 emonpi systemd[1]: emonhub.service start request repeated too quickly, refusing to start.
Jul 24 23:13:04 emonpi systemd[1]: Failed to start emonHub service description.
Jul 24 23:13:04 emonpi systemd[1]: Unit emonhub.service entered failed state.

Then I ran

[email protected](ro):emonhub$ sudo systemctl cat emonhub.service
# /home/pi/emonhub/service/emonhub.service [Unit] Description=emonHub service description DefaultDependencies=no Before=shutdown.target Conflicts=shutdown.target Requires=local-fs.target After=sysinit.target syslog.target local-fs.target
[Service]
User=emonhub
PIDFile=/var/run/emonhub.pid
ExecStart=/usr/local/bin/emonhub/emonhub.py --config-file=/etc/emonhub/emonhub.conf --logfile=/var/log/emonhub/emonhu
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/log/emonhub/
ExecStartPre=/bin/chgrp -R emonhub /var/log/emonhub/
ExecStartPre=/bin/chmod 775 /var/log/emonhub/
Type=simple
Restart=always
`
[Install]
WantedBy=multi-user.target

Then I ran:

[email protected](ro):emonhub$ ls -la /{etc,lib}/systemd/system/emonhub.service
ls: cannot access /etc/systemd/system/emonhub.service: No such file or directory
lrwxrwxrwx 1 root root 40 Jul 24 23:12 /lib/systemd/system/emonhub.service -> /home/pi/emonhub/service/emonhub.service

And last I ran:

[email protected](ro):emonhub$ ls -la /etc/init.d/emonhub
ls: cannot access /etc/init.d/emonhub: No such file or directory

Sorry I’m a bit too tied up to look into this right now, but a brief look at the man page i’m now thinking that “-b” should have been “-B” but I will need to read up some more later. Many moons ago I used to switch branch and then switch back using something like

git checkout -f <someotherbranch>
git checkout <branch>

but I changed that habit when I found a way to reset the branch in one move, shame I can’t recall what that move was now!

Or I think the other reset command is something like

git reset --hard

but I haven’t much experience of using it myself, since there’s nothing you want to retain in the way of local changes, I don’t think it can hurt.

[edit - I was just about to post this when I noticed your edit], so the comments below relate to the updated content]

Looking at your logs above, it seems you now have the systemd symink as the service unit path has changed, in fact the whole service unit content has changed and that would only happen if the repo had updated, so perhaps the reset has worked at some point?

So the last 3 tests above ( from the second “then I ran” on wards) all return the correct info. But the previous “status” doesn’t look right. Firstly it says “disabled” at the end of the loaded line, it should be “enabled”.

Try

sudo systemctl daemon-reload
sudo systemctl --now enable emonhub.service

and then check the status again.

[edit 2] When you post code or logs try using 3x backticks (```) on the lines before and after your code/log, it formats much better. eg

```
code goes here
```

Excellent, thanks for the tip with copying logs. Next time …

First command ran fine, without any output though
Second command fails with

[email protected](ro):emonhub$ sudo systemctl --now enable emonhub.service
systemctl: unrecognized option ‘–now’