The way the emonpi update scripts “log” is simply to redirect “the output” to a file instead of the screen. Because the scripts are running other command line utilities some of the “output” from them can be either stdout
or stderr
(and some can even detect if they are being run from the command line and redirect stderr
to stdout
in that instance).
The point here is that there are no “error” messages being logged to /home/pi/data/emonpiupdate.log with a standard emonpi update via emoncms, but I found they are logged via a “firstbootupdate”.
The standard emonpi update seems to be done by the command /home/pi/emonpi/service-runner-update.sh > /home/pi/data/emonpiupdate.log
being issued from the cron controlled service-runner
, If I run that command from the commandline I see all the missing messages in the terminal as they are not being redirected to emonpiupdate.log
.
That output in the terminal is incomplete and although recognizable, it doesn’t make much sense as the bulk of the output is going to “emonpiupdate.log”. I have since found all the missing messages are sometimes logged to /var/log/service-runner.log
.
By editing the service-runner @ line 21 to
$script 2>&1 >> $logfile 2>&1
so the command actually issued is
/home/pi/emonpi/service-runner-update.sh 2>&1 >> /home/pi/data/emonpiupdate.log 2>&1
it matches the command issued by the firstbootupdate
but the log still isn’t as complete, there are still error messages not being passed to emonpiupdate.log and landing in service-runner.log instead, despite the same command with the same redirects.
I have also noticed that although it says to add “/home/pi/emonpi/./firstbootupdate
” to /etc/rc.local
in the firstbootupdate script this seems to have changed at some point to be
su pi -c '/home/pi/emonpi/./firstbootupdate'
so that previous “test” command was effectively incorrect and should have been
rpi-rw && rm /home/pi/data/emonpiupdate.log && /home/pi/emonpi/firstbootupdate
ie no sudo, I had put that in because rc.local is run as root but the “su pi” will run it as user pi. Alas this doesn’t resolve the missing messages, but it does explain the
update running as root: remove sudo crontab service runner entries
switching to Pi user & restarting script
**MANUAL SYSTEM REBOOT REQUIRED**
Please shutdown and reboot emonPi then run Update again
in @jon’s last log.
Although you had resolved all the local change stashes etc, this latest log has all the branch details that were previously missing and the avrdude printout is back, the pip version notice is there and there seems to be some errors reported about the new mqtt_input unit too.
With the edit to the service-runner above the output to service-runner.log on my emonPi is currently
STARTING: /home/pi/emonpi/service-runner-update.sh > /home/pi/data/emonpiupdate.log
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
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 (17898 bytes):
Writing | ################################################## | 100% 2.52s
avrdude-original: 17898 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 17898 bytes
avrdude-original: reading on-chip flash data:
Reading | ################################################## | 100% 1.92s
avrdude-original: verifying ...
avrdude-original: 17898 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
Already on 'emonpi'
Failed to restart mqtt_input.service: Unit mqtt_input.service failed to load: Invalid argument. See system logs and 'systemctl status mqtt_input.service' for details.
COMPLETE: /home/pi/emonpi/service-runner-update.sh > /home/pi/data/emonpiupdate.log
This is also where any messages from git about local changes aborting a pull sometimes end up, I’m now guessing it depended on which method I had used (service-runner or firstbootupdate) but there are very clear differences between the 2 methods that go beyond the make up of the command line and I have not managed to locate why yet and to be honest I feel it might be beyond me.