Emonhub process cannot open /var/log/emonhub/emonhub.log after update

After a recent full update the emonhub process was failing to start so I investigated the syslog file and found that the start script was exiting with permissions failure on access to the emonhub log file.

I checked /var/log/emonhub/emonhub.log and it was owner was emonhub:emonhub with rw for owner but only r for group.

The emonhub process runs as user pi, which is a member of the emonhub group, so it looks like there is an error somewhere the new log file creation or logrotate process not setting the group permissions correctly.

The log stopped getting written to at 23:56 so I assume it happened at the first rotation after the update. Then on next reboot the emonhub process would not start.

I fixed temporarily by changing the log file perms but not sure will happen on next rotation.

@TrystanLea

@Warren_McDonald - can you raise an issue on GitHub, please?

Trystan has changed the emonhub usersetup, and this is a byproduct.

Thanks for raising, I think I know what’s happening here, I think we need to update the permissions on the log within the update process, will sort that now. This relates to a change I made yesterday.

1 Like

I’ve pushed up the fix for this and updated stable to include as well.

1 Like

Hello,

I think I’m having the same sort of problem and have attached info on my system.
Emonhub keeps trying to run but won’t and emonhub.log remains empty. I changed permissions on the log file to 775 but that didn’t help.
My server is an RPI4 with 8GB of memory. It’s receiving data from MQTT clients so that part is working correctly. The system has been working fine for several years so I’m not sure what happened.
I have a basic knowledge of Linux but am not a programmer. I have received lots of help from members of this forum. Please let me know if you need additional information.
Thanks in advance
@bgrattan

emonhub_error.txt (13.5 KB)

I changed permissions on emonhub.log to 777 and everything took off.
Not sure this was the correct thing to do but at least it’s working. Thanks

Hello @bgrattan can you try running emonhub install again, just to make sure it’s all correctly configured:

cd /opt/openenergymonitor/emonhub
./install.sh

I would recommend doing that even if it’s working now as I think you might still have the incorrect service file

Thanks, I did that and it’s still running ok. Saw it made the change in emonhub.log:
-rw-r–r-- 1 pi pi 549 Nov 12 16:12 emonhub.log

Cheers,
Bob

Perfect thanks!

Thanks @TrystanLea,

I have updated the emonhub component on stable and it has changed the log file owner and group to pi.
I assume this would have also replaced the service file.

Cheers,

Warren

Yes it sounds like that’s correct for you now, cheers!

Is this the error in question? If so, it still persists today even after full update, reboots and trying Start Emonhub

[Possibly related to EmonTH v2 and pulsecount stoppet working - #2 by Robert.Wall - Moderator (RW) ]

If you can SSH in and view the systemlog then that will help solve it.

What user should this be run under? I have logged in as “pi”, but as a total n00b on these things, I wouldn’t know…

I tried chmod 777 on the emonhub.log file but only got this:
image

sudo chmod … helps

Under the pi user

Its about…17 years since I used UNIX, and I have never used Linux. At the time I was just about able to use “su” in controlled environments, I tried here and gave up, didn’t think of “sudo”. Thanks!

I ran emonhub/install.sh first. A lot happened, but did not appear to fix the problem I reported in the related thread:

But changing the permissions on emonhub.log to 777 did the trick and solved both the problem with the two emonth units and the pulse counter.

It might be worth trying the following:

sudo rm -rf /var/log/emonhub
sudo systemctl restart emonhub

that will delete the log and log directory, when you then restart emonhub it should create both again, all with the correct permissions.