wp redis cli hangs
-
Running wp redis cli hangs. Can’t figure out why. Though it seems that wp redis is runnning fine:
$ wp redis info
+——————-+———–+
| Field | Value |
+——————-+———–+
| status | connected |
| used_memory | 2.61M |
| uptime | 0 days |
| key_count | 254 |
| instantaneous_ops | 63/sec |
| lifetime_hitrate | 79.41% |
| redis_host | 127.0.0.1 |
| redis_port | 6379 |
| redis_auth | |
| redis_database | 0 |
+——————-+———–+$ wp redis cli
…
-
Hey @ddyok,
Were you able to track this down?
WP Redis simply calls the equivalent of WP_CLI::launch(‘redis-cli’), which uses proc_open() under the hood.
Notably, the
wp redis infocommand uses PhpRedis to fetch the relevant data, not the Redis CLI interface.Here are a few questions that might help you debug further:
- What happens when you call
redis-clidirectly (with the relevant connection details)? - If you use
wp shell, what happens when you callWP_CLI::launch()with some other command? - What system and shell are you on?
Hey Daniel,
>What happens when you call redis-cli
That works fine. So this not a very urgent matter. Maybe just to figure out what’s going on.
> wp shell, what happens when you call WP_CLI::launch()
wp> WP_CLI::launch()
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_CLI::launch(), 0 passed in phar:///usr/local/bin/wp/vendor/wp-cli/shell-command/src/WP_CLI/Shell/REPL.php(46) : eval()’d code on line 1 and at least 1 expected in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php:1029Wonder what this is about? Trying to find out. I don’t know if it’s related to you.
> What system and shell are you on?
Linux 4.15.0-88-generic #88-Ubuntu SMPx86_64 x86_64 x86_64 GNU/Linux
with bash
Thank you.
Thanks for the update, @ddyok.
Given
redis-cliworks, and WP Redis simply calls WP-CLI functions, it seems like this issue is specific to WP-CLI and not WP Redis.wp> WP_CLI::launch()
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_CLI::launch(), 0 passed in phar:///usr/local/bin/wp/vendor/wp-cli/shell-command/src/WP_CLI/Shell/REPL.php(46) : eval()’d code on line 1 and at least 1 expected in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php:1029Wonder what this is about? Trying to find out. I don’t know if it’s related to you.
You’d need to pass a command as an argument to
WP_CLI::launch(). TryWP_CLI::launch( 'echo "Hello World"' );Also, can you share
wp --info?@schlessera Have you seen
WP_CLI::launch()hang in this manner before? Any ideas on how to debug further?$ wp shell
wp> WP_CLI::launch( ‘echo “Hello World”‘ );
=> int(0)
wp> exit
$ wp –info
OS: Linux 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.2
PHP version: 7.2.24-0ubuntu0.18.04.3
php.ini used: /etc/php/7.2/cli/php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /var/www/wordpress
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0Huh.
Given that
WP_CLI::launch( 'echo "Hello World"' );works as expected, maybe it’s not WP-CLI after all.Can you add
var_dump( $cmd );after this line and then, separately, try to run the command that’s dumped? I wonder whether there’s some way the command is formed that’s causing an issue on your system.Added var_dump( $cmd ); to cli.php (line 34, after $cmd =), and it still hangs.
It didn’t print out the value of
$cmd?Nope, nothing was dumped.
Ok. Can you add
var_dump()throughout that method to see where the execution hangs?I just tested on my system. What I’ve seen so far:
–
wp redis clihangs on my system as well
– The command it tries to run on my system isredis-cli -h "'127.0.0.1'" -p "'6379'" -a "''" -n "0"
– If I run that comand manually, I get the following output:Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. Could not connect to Redis at '127.0.0.1':0: nodename nor servname provided, or not known not connected>– This means Redis was not active on that site. So I used valet to enable Redis:
valet redis enable=> this one also hangs!Given the above, my assumption is that Redis changed its CLI behavior (whether intentionally or not) and it doesn’t work as expected anymore.
-
This reply was modified 6 years, 2 months ago by
Alain Schlesser.
Thanks @schlessera!
I’m embarrassed to admit… I guess I didn’t even test
wp redis clilocally. As soon as I tried it (again?), I was able to reproduce the issue.In debugging it further, it seems like the behavior of
WP_CLI\Utils\esc_cmd()andWP_CLI::launch()have both changed sincewp redis cliwas written.WP_CLI\Utils\esc_cmd( 'redis-cli -h "%s" -p "%s" -a "%s" -n "%d"' ), while somewhat incorrect, used to accommodate the double-quoting. I’ve removed the quotes and now it produces a singularly-quoted string as expected.WP_CLI::launch()usedarray( STDIN, STDOUT, STDERR )as the default$descriptorspecunless$return_detailed = truewas provided. It looks like I accidentally broke this in 2014. I’m not sure whywp redis clidid work in 2016 but, regardless, switching back toproc_open( $cmd, array( STDIN, STDOUT, STDERR ), $pipes );does the trick.@ddyok I’ve just tagged WP Redis v0.8.3. Thanks for your help tracking this issue down!
- What happens when you call
The topic ‘wp redis cli hangs’ is closed to new replies.