Emoncms on Ubuntu 20.04 with scripts

pi@emoncms:~$  which python2
/usr/bin/python2
pi@emoncms:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal

Try editing the #! in the service-runner script and in the service file to point to python2.

The fly in the ointment here might be that redis may not have installed for python2.

If not you will get an error.

What beats me is why it worked when you did the manual install! It shouldn’t have.

Edited service-runner.py with #!/usr/bin/python2

then got

pi@emoncms:/var/www/emoncms/scripts/services/service-runner$ journalctl -f -u service-runner
-- Logs begin at Tue 2020-08-11 15:23:57 UTC. --
Aug 12 07:25:44 emoncms systemd[24621]: service-runner.service: Failed at step EXEC spawning /usr/bin/python: No such file or directory
Aug 12 07:25:44 emoncms systemd[1]: service-runner.service: Main process exited, code=exited, status=203/EXEC
Aug 12 07:25:44 emoncms systemd[1]: service-runner.service: Failed with result 'exit-code'.
Aug 12 07:26:14 emoncms systemd[1]: service-runner.service: Scheduled restart job, restart counter is at 1676.
Aug 12 07:26:14 emoncms systemd[1]: Stopped Emoncms service-runner Input Script.
Aug 12 07:26:14 emoncms systemd[1]: Started Emoncms service-runner Input Script.
Aug 12 07:26:14 emoncms systemd[24642]: service-runner.service: Failed to execute command: No such file or directory
Aug 12 07:26:14 emoncms systemd[24642]: service-runner.service: Failed at step EXEC spawning /usr/bin/python: No such file or directory
Aug 12 07:26:14 emoncms systemd[1]: service-runner.service: Main process exited, code=exited, status=203/EXEC
Aug 12 07:26:14 emoncms systemd[1]: service-runner.service: Failed with result 'exit-code'.

then edited service-runner.service and changed this line to also reflect python2

[Service]
Type=idle
ExecStart=/usr/bin/python2 /var/www/emoncms/scripts/services/service-runner/service-runner.py
User=pi

then got this

pi@emoncms:/var/www/emoncms/scripts/services/service-runner$ journalctl -f -u service-runner
-- Logs begin at Tue 2020-08-11 15:23:57 UTC. --
Aug 12 07:30:47 emoncms systemd[1]: service-runner.service: Main process exited, code=exited, status=1/FAILURE
Aug 12 07:30:47 emoncms systemd[1]: service-runner.service: Failed with result 'exit-code'.
Aug 12 07:31:02 emoncms systemd[1]: Stopped Emoncms service-runner Input Script.
Aug 12 07:31:04 emoncms systemd[1]: Started Emoncms service-runner Input Script.
Aug 12 07:31:04 emoncms service-runner[24807]: Traceback (most recent call last):
Aug 12 07:31:04 emoncms service-runner[24807]:   File "/var/www/emoncms/scripts/services/service-runner/service-runner.py", line 11, in <module>
Aug 12 07:31:04 emoncms service-runner[24807]:     import redis
Aug 12 07:31:04 emoncms service-runner[24807]: ImportError: No module named redis
Aug 12 07:31:04 emoncms systemd[1]: service-runner.service: Main process exited, code=exited, status=1/FAILURE
Aug 12 07:31:04 emoncms systemd[1]: service-runner.service: Failed with result 'exit-code'.

If I read this correct the python is sorted but now there is a issue with redis that needs to be resolved?

Or should I stop wasting time and install Ubuntu 18.04?

You could - might be simpler as long as Python is still there.

You need to install pip for python2.

Should work and then you need

pip install redis

or

pip2 install redis

Still don’t understand why it worked when you did it manually. It shouldn’t have!

thanks, that sorted it service-runner is now operational and the backup function is also working.

image

Do I need to worry about the log file that doesn’t exist and update not working via the web interface when using Ubuntu?

Could you post the commands you needed to do to get it working please for reference?

If you

journalctl -f -u service-runner

and then run the update you should see something like this or an error.

Aug 11 17:28:17 emonpi service-runner[596]: Starting service-runner
Aug 11 17:28:17 emonpi service-runner[596]: Connected to redis-server
Aug 12 09:38:53 emonpi service-runner[596]: Got flag: /opt/openenergymonitor/EmonScripts/update/service-runner-update.sh emoncms none ttyAMA0>/var/log/emoncms/emonpiupdate.log

I will post the command up to now to get it working, we probably need to change the topic to Installing Emoncms on Ubuntu 20.04 with scripts.

This is what I get with journalctl -f -u service-runner

pi@emoncms:~$ journalctl -f -u service-runner
-- Logs begin at Tue 2020-08-11 15:23:57 UTC. --
Aug 12 08:08:22 emoncms systemd[1]: Started Emoncms service-runner Input Script.
Aug 12 08:08:28 emoncms service-runner[762]: Starting service-runner
Aug 12 08:08:28 emoncms service-runner[762]: Connected to redis-server
Aug 12 08:12:56 emoncms service-runner[762]: Got Termination signal, exiting
Aug 12 08:12:56 emoncms systemd[1]: Stopping Emoncms service-runner Input Script...
Aug 12 08:12:56 emoncms systemd[1]: service-runner.service: Succeeded.
Aug 12 08:12:56 emoncms systemd[1]: Stopped Emoncms service-runner Input Script.
-- Reboot --
Aug 12 08:13:43 emoncms systemd[1]: Started Emoncms service-runner Input Script.
Aug 12 08:13:49 emoncms service-runner[755]: Starting service-runner
Aug 12 08:13:50 emoncms service-runner[755]: Connected to redis-server

To get it working was to do a fresh install using the scripts as the “pi” username and update the config.ini file to non-pi environment.

Install python2 becuase it was not released with Ubuntu 20.04
sudo apt install python2

Then edited service-runner.py file with #!/usr/bin/python2 ontop
and edited service-runner.service file and changed this line to also reflect python2

[Service]
Type=idle
ExecStart=/usr/bin/python2 /var/www/emoncms/scripts/services/service-runner/service-runner.py
User=pi

next, followed these instructions to install pip

https://linuxize.com/post/how-to-install-pip-on-ubuntu-20.04/#installing-pip-for-python-2

and then installed redis with

pip install redis

reboot the server

If you run the update while doing that, do you see a ‘got flag’ message?

I see no ‘got flag’ message in the terminal after issuning journalctl -f -u service-runner and then update via the web interface.

The web interface log does display invalid serial port type message before it change the message to
/var/log/emoncms/emonpiupdate.log does not exist

You said that that backup worked though? Odd.

Does the log file exist? If not

touch /var/log/emoncms/emonpiupdate.log

might need sudo touch then do

sudo chmod 666 /var/log/emoncms/emonpiupdate.log

which is what this does

Yes, backup is working, just tested it again.

Now the log file /var/log/emoncms/emonpiupdate.log exist after the touch

Update on the web interface now doesn’t complain about the log file, just briefly display invalid serial port type then disapears.

I checked the /var/log/emoncms/emonpiupdate.log file and its empty

Can you try just updating emoncms rather than a full update please?

Same message and issue with
Full update,
UPDATE EMONCMS ONLY
and UPDATE EMONHUB ONLY

all reacting the same with invalid serial port type

In the UI, next to the Update Firmware, what is listed in the dropdown?

image

This is generating the error

which is a very recent update so might be buggy!

Try editing that line and adding an empty string in.

I Have added, hope its correct but its not working.

if (!in_array($serial_port,array("","ttyAMA0","ttyUSB0","ttyUSB1","ttyUSB2"))) return "Invalid >