swoole not detecting mysql data changes

57 Views Asked by At

I have a project to work with swoole. I thought it worked fine when running the swoole. When I check the database, the swoole doesn't detect any changes of my data from database

enter image description here

When I set is_paired to 1, the server reads only the previous value which is 0.

$server = new Swoole\Server($_SERVER['HOST'], $_SERVER['PORT'], SWOOLE_PROCESS, SWOOLE_SOCK_UDP);
       
$server->set([

    // 'daemonize' => 1,
    // 'pid_file' => './swoole-reactor.pid',

    'user' => 'www-data',
    'group' => 'www-data',

    'reactor_num' => 2,
    'worker_num' => 8,

    // 'enable_coroutine' => true,
    // 'max_coroutine' => 2,
    'enable_coroutine' => true,
    'max_coroutine' => 3000,
    'send_yield' => false,
    'reload_async' => true,
    // 'max_request_execution_time' => 10,

    // Logging
    'log_level' => 0,
    'log_file' => './swoole.log',
    'log_rotation' => SWOOLE_LOG_ROTATION_DAILY,
    'log_date_format' => '%Y-%m-%d %H:%M:%S',
    'log_date_with_microseconds' => false,
]);

$server->on('Packet', function ($server, $payload, $clientInfo) {

    /** @var DeviceRepository **/
    $deviceRepository = $this->entityManager->getRepository(Device::class);
    $device = $deviceRepository->find(506);
    echo ($device->getIsPaired());
});

Did I miss the setup of my server? I found another solution by adding $server->reload() but when I pushed it to the server I got another problem: the permission.

13:46:31 WARNING   [php] Warning: Swoole\Server::reload(): failed to send the reload signal, Error: Operation not permitted[1] ["exception" => ErrorException { …}]

I'm not sure adding server->reload() is a good idea to refresh the server whenever there are database changes.

0

There are 0 best solutions below