Skip to content

service-runner.py ignores backup and postprocess requests when emoncms prefix set to "emoncms" #1785

Description

@steversig

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions