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

webman 自定义命令中 使用Cache::ChCreateListener,再启动时报错 #3

Closed
df131 opened this issue May 16, 2024 · 0 comments
Closed

Comments

@df131
Copy link

df131 commented May 16, 2024

完整代码如下
`<?php

namespace app\command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Workbunny\WebmanSharedCache\Cache;

class Test extends Command {
protected static $defaultName = 'Test';
protected static $defaultDescription = '测试';

protected function configure() {
    $this->addArgument('name', InputArgument::OPTIONAL, 'Name description');
}
protected function execute(InputInterface $input,OutputInterface $output):int{
    $output->writeln('开始执行--start');
    Cache::ChCreateListener('test',1,function ($channelKey, $workerId, $message)use($output){
        dump($channelKey,$workerId,$message);

// $output->writeln('channel-->start');
// $output->writeln('channel-->start'.date('Y-m-d H:i:s'));
});
return 1;
}
}`

报错:
Fatal error: Uncaught Error: Event driver error. in /Users/winds/Project/php/new/api/vendor/workbunny/webman-shared-cache/src/Future.php:37
Stack trace:
#0 /Users/winds/Project/php/new/api/vendor/workbunny/webman-shared-cache/src/Traits/ChannelMethods.php(155): Workbunny\WebmanSharedCache\Future::add(Object(Closure), Array, NULL)
#1 [internal function]: Workbunny\WebmanSharedCache\Cache::Workbunny\WebmanSharedCache\Traits{closure}()
#2 /Users/winds/Project/php/new/api/vendor/workbunny/webman-shared-cache/src/Traits/BasicMethods.php(149): call_user_func(Object(Closure))
#3 [internal function]: Workbunny\WebmanSharedCache\Cache::Workbunny\WebmanSharedCache\Traits{closure}('#lock#test')
#4 /Users/winds/Project/php/new/api/vendor/workbunny/webman-shared-cache/src/Traits/BasicMethods.php(146): apcu_entry('#lock#test', Object(Closure))
#5 /Users/winds/Project/php/new/api/vendor/workbunny/webman-shared-cache/src/Traits/ChannelMethods.php(139): Workbunny\WebmanSharedCache\Cache::_Atomic('test', Object(Closure), true)
#6 [internal function]: Workbunny\WebmanSharedCache\Cache::_ChCreateListener('test', 1, Object(Closure))
#7 /Users/winds/Project/php/new/api/vendor/workbunny/webman-shared-cache/src/Cache.php(45): call_user_func(Array, 'test', 1, Object(Closure))
#8 /Users/winds/Project/php/new/api/app/command/Test.php(20): Workbunny\WebmanSharedCache\Cache::__callStatic('ChCreateListene...', Array)
#9 /Users/winds/Project/php/new/api/vendor/symfony/console/Command/Command.php(279): app\command\Test->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /Users/winds/Project/php/new/api/vendor/symfony/console/Application.php(1031): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /Users/winds/Project/php/new/api/vendor/symfony/console/Application.php(318): Symfony\Component\Console\Application->doRunCommand(Object(app\command\Test), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /Users/winds/Project/php/new/api/vendor/symfony/console/Application.php(169): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /Users/winds/Project/php/new/api/webman(57): Symfony\Component\Console\Application->run()
#14 {main}

chaz6chez added a commit that referenced this issue May 17, 2024
chaz6chez added a commit that referenced this issue May 17, 2024
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

No branches or pull requests

2 participants