Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing redis namespace when starting workers #5283

Closed
RichieB2B opened this issue Oct 8, 2019 · 6 comments · May be fixed by wa0x6e/php-resque-ex#52
Closed

Missing redis namespace when starting workers #5283

RichieB2B opened this issue Oct 8, 2019 · 6 comments · May be fixed by wa0x6e/php-resque-ex#52

Comments

@RichieB2B
Copy link
Contributor

RichieB2B commented Oct 8, 2019

My app/Plugin/CakeResque/Config/config.php says:

$config['CakeResque'] = array(
        'Redis' => array(
                'host' => 'localhost',          // Redis server hostname
                'port' => 6379,                         // Redis server port
                'database' => 0,                        // Redis database number
                'namespace' => 'resque',        // Redis keys namespace
                'password' => null                      // Redis password
        ),

however, when starting the workers from the command line the namespace is missing in several places:

$ redis-cli monitor
OK
1570568229.351190 [0 127.0.0.1:51036] "SMEMBERS" "resque:workers"
1570568229.753919 [0 127.0.0.1:51038] "HSET" "ResqueWorker" "0" "a:10:{s:8:\"interval\";i:5;s:5:\"queue\";s:7:\"default\";s:4:\"help\";b:0;s:7:\"verbose\";b:0;s:5:\"quiet\";b:0;s:4:\"type\";s:7:\"regular\";s:3:\"log\";s:72:\"/var/www/MISP/app/tmp/logs/resque-worker-error.log\";s:7:\"workers\";i:1;s:4:\"user\";s:6:\"apache\";s:3:\"Log\";a:2:{s:7:\"handler\";s:12:\"RotatingFile\";s:6:\"target\";s:59:\"/var/www/MISP/app/tmp/logs/resque.log\";}}"
1570568230.156650 [0 127.0.0.1:51040] "HSET" "ResqueWorker" "0" "a:10:{s:8:\"interval\";i:5;s:5:\"queue\";s:4:\"prio\";s:4:\"help\";b:0;s:7:\"verbose\";b:0;s:5:\"quiet\";b:0;s:4:\"type\";s:7:\"regular\";s:3:\"log\";s:72:\"/var/www/MISP/app/tmp/logs/resque-worker-error.log\";s:7:\"workers\";i:1;s:4:\"user\";s:6:\"apache\";s:3:\"Log\";a:2:{s:7:\"handler\";s:12:\"RotatingFile\";s:6:\"target\";s:59:\"/var/www/MISP/app/tmp/logs/resque.log\";}}"
1570568230.568221 [0 127.0.0.1:51042] "HSET" "ResqueWorker" "0" "a:10:{s:8:\"interval\";i:5;s:5:\"queue\";s:5:\"cache\";s:4:\"help\";b:0;s:7:\"verbose\";b:0;s:5:\"quiet\";b:0;s:4:\"type\";s:7:\"regular\";s:3:\"log\";s:72:\"/var/www/MISP/app/tmp/logs/resque-worker-error.log\";s:7:\"workers\";i:1;s:4:\"user\";s:6:\"apache\";s:3:\"Log\";a:2:{s:7:\"handler\";s:12:\"RotatingFile\";s:6:\"target\";s:59:\"/var/www/MISP/app/tmp/logs/resque.log\";}}"
1570568230.977489 [0 127.0.0.1:51044] "HSET" "ResqueWorker" "0" "a:10:{s:8:\"interval\";i:5;s:5:\"queue\";s:5:\"email\";s:4:\"help\";b:0;s:7:\"verbose\";b:0;s:5:\"quiet\";b:0;s:4:\"type\";s:7:\"regular\";s:3:\"log\";s:72:\"/var/www/MISP/app/tmp/logs/resque-worker-error.log\";s:7:\"workers\";i:1;s:4:\"user\";s:6:\"apache\";s:3:\"Log\";a:2:{s:7:\"handler\";s:12:\"RotatingFile\";s:6:\"target\";s:59:\"/var/www/MISP/app/tmp/logs/resque.log\";}}"
1570568231.063432 [0 127.0.0.1:51046] "HKEYS" "ResqueWorker"
1570568231.064023 [0 127.0.0.1:51046] "GET" "resque:ResqueSchedulerWorker"
1570568231.064389 [0 127.0.0.1:51046] "DEL" "resque:ResqueSchedulerWorker"

As a result the workers are not seen by MISP. I'm really lost why this is happening..

@RichieB2B
Copy link
Contributor Author

Finally got the workers to show up with this patch:

--- a/app/Vendor/kamisama/php-resque-ex/lib/Resque/Redis.php    2015-01-29 00:00:53.000000000 +0100
+++ b/app/Vendor/kamisama/php-resque-ex/lib/Resque/Redis.php    2019-10-09 00:07:22.988921335 +0200
@@ -73,6 +73,7 @@
                                'del',
                                'type',
                                'keys',
+                               'hkeys',
                                'expire',
                                'ttl',
                                'move',
@@ -91,6 +92,7 @@
                                'ltrim',
                                'lindex',
                                'lset',
+                               'hset',
                                'lrem',
                                'lpop',
                                'rpop',
@@ -147,7 +149,7 @@
                 */
                public function __call($name, $args) {
                        $args = func_get_args();
-                       if(in_array($name, $this->keyCommands)) {
+                       if(in_array(strtolower($name), $this->keyCommands)) {
                                $args[1][0] = self::$defaultNamespace . $args[1][0];
                        }
                        try {

@RichieB2B
Copy link
Contributor Author

My patch looks an awful lot like wa0x6e/php-resque-ex@c8764c4 that was committed but apparently never included in a release. The kamisama / wa0x6e version looks pretty abandoned to me.

OTOH if I read Redis.php correctly Redisent is only supposed to be used when redis.so is not loaded. I'll look into that.

@iglocska
Copy link
Member

iglocska commented Oct 9, 2019

Indeed, if I remember correctly Redisent was just broken as hell - but luckily you should never have to use it unless something went wrong with the install ad php-redis is not available.

@RichieB2B
Copy link
Contributor Author

Well, it works again with my patch. 🙃 Umask bit me and set redis.ini to 600.. should revert to redis.so once I fix it.

@iglocska
Copy link
Member

iglocska commented Oct 9, 2019

Ah cool 🤣

@RichieB2B
Copy link
Contributor Author

redis.ini fixed, redis.so loaded, Redisent no longer used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants