borpin
(Brian Orpin)
21 June 2022 20:29
37
@bwduncan - can you have a look at this, please?
Not sure why this has not been noticed before.
opened 03:43PM - 26 Feb 22 UTC
emonSD-21Jul21 on a Raspberrypi 3B
manually running emoncms-export.sh works
…
/default-settings.ini:43:; Only a prefix of 'emoncms' or '' will be recognised by service-runner
Only "" works on emonSD-21Jul21 which I think covers 95% of the users
If you installed it direct from Git then I think that you get a prefix of 'emoncms' which is what my other emoncms setup has
Cause of problem is /var/www/emoncms/scripts/services/service-runner/service-runner.py line 15
KEYS = ["service-runner", "emoncms:service-runner"]
KEYS are what keys service-runner processes
"emoncms:service-runner" has a ":" in the middle of it but the php scripts that set a redis prefix do not add the ":"
So service-runner.py ignores the requests
$ cd /var/www/emoncms
$ grep -rnw . -e '$redis->setOption' *.php
./scripts/feedwriter.php:37: if (!empty($settings['redis']['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $settings['redis']['prefix']);
./scripts/input_queue_processor.php:32: if (!empty($redis_server['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $redis_server['prefix']);
./scripts/services/emoncms_mqtt/emoncms_mqtt.php:86: if (!empty($settings['redis']['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $settings['redis']['prefix']);
./scripts/export_montly_cron.php:38: if (!empty($redis_server['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $redis_server['prefix']);
./scripts/phpmqtt_input.php:88: if (!empty($settings['redis']['prefix'])) $redis->setOption(Redis::OPT_PREFIX, $settings['redis']['prefix']);
./index.php:40: $redis->setOption(Redis::OPT_PREFIX, $settings['redis']['prefix']);
index.php:40: $redis->setOption(Redis::OPT_PREFIX, $settings['redis']['prefix']);
**Quick fix**
Remove ":" from service-runner.py line 15
KEYS = ["service-runner", "emoncmsservice-runner"]
**To reproduce**
set settings.ini to
[redis]
prefix = 'emoncms'
restart web server
submit a Backup from Backup, Export, Create Backup - nothing happens
$ redis-cli --scan | grep emoncmsservice-runner
emoncmsservice-runner
$ redis-cli LRANGE emoncmsservice-runner 0 -1
1) "/opt/emoncms/modules/backup/emoncms-export.sh /tmp/emoncms-flag-export>/var/log/emoncms/exportbackup.log"
Wait a while and its still there and I get no export
I think that this has been in there rather a long time as the previous version of emonSD had the bug too. I just got mired in redis php versions and ended up running the shell scripts when I couldn't work out what was causing it
I also found this thread Multi-instance service-runner @Greebo has the behaviour of Redis changed do you know such that the colon isn’t added by default anymore after the prefix?
@TrystanLea FYI