wa0x6e / Cake-Resque

Resque plugin for CakePHP : for creating background jobs that can be processed offline later
MIT License
159 stars 56 forks source link

Proper redis host/port not always passed #12

Closed josegonzalez closed 11 years ago

josegonzalez commented 11 years ago

In the shell, whenever you call

    $workersCountBefore = Resque::Redis()->scard('workers');

That does not set a port or anything for the Redis class. So then it tries to connect to null which fails.

    Warning Error: Redis::pconnect(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in [/Users/jose/Sites/work/michaelli.phpfogapp.com/app/Plugin/CakeResque/vendor/kamisama/php-resque-ex/lib/Resque/Redis.php, line 22]

    Error: Redis server went away
    #0 /Users/jose/Sites/work/michaelli.phpfogapp.com/app/Plugin/CakeResque/vendor/kamisama/php-resque-ex/lib/Resque/Redis.php(23): Redis->setOption(2, 'resque:')
    #1 /Users/jose/Sites/work/michaelli.phpfogapp.com/app/Plugin/CakeResque/vendor/kamisama/php-resque-ex/lib/Resque/Redis.php(17): RedisApi->establishConnection()
    #2 /Users/jose/Sites/work/michaelli.phpfogapp.com/app/Plugin/CakeResque/vendor/kamisama/php-resque-ex/lib/Resque.php(97): RedisApi->__construct('', '')
    #3 /Users/jose/Sites/work/michaelli.phpfogapp.com/app/Plugin/CakeResque/Console/Command/CakeResqueShell.php(237): Resque::redis()
    #4 /Users/jose/Sites/work/michaelli.phpfogapp.com/lib/Cake/Console/Shell.php(390): CakeResqueShell->start()
    #5 /Users/jose/Sites/work/michaelli.phpfogapp.com/lib/Cake/Console/ShellDispatcher.php(201): Shell->runCommand('start', Array)
    #6 /Users/jose/Sites/work/michaelli.phpfogapp.com/lib/Cake/Console/ShellDispatcher.php(69): ShellDispatcher->dispatch()
    #7 /Users/jose/Sites/work/michaelli.phpfogapp.com/app/Console/cake.php(33): ShellDispatcher::run(Array)
    #8 {main}
josegonzalez commented 11 years ago

Note, this was caused by me being a dumbass and not properly calling Resque::setBackend() with your updated configure paths.

wa0x6e commented 11 years ago

As long as you enqueue jobs with CakeResque::enqueue() instead of Resque::enqueue(), you should never have issues with redis connection. Resque::setBackend() will be set automatically.

josegonzalez commented 11 years ago

This was when running the cake shell, not enqueuing the jobs. On Oct 3, 2012 10:49 AM, "Wan Qi Chen" notifications@github.com wrote:

As long as you enqueue jobs with CakeResque::enqueue() instead of Resque::enqueue(), you should never have issues with redis connection. Resque::setBackend() will be set automatically.

— Reply to this email directly or view it on GitHubhttps://github.com/kamisama/Cake-Resque/issues/12#issuecomment-9108840.

wa0x6e commented 11 years ago

Ah ok.

Resque::setBackend() should called in Lib/CakeResque.php, a file automatically required at the end of the bootstrap.php