/** * Cleaning all asynchronous client processes registered by cache files * * @param bool $throwException * @param null|LOLClientInterface $client * * @throws \RuntimeException */ protected function cleanAsyncClients($throwException = false, $client = null) { $this->logger->info('Cleaning cached async clients...'); $cachePath = __DIR__ . '/../../../../' . ConfigurationLoader::get('cache.path') . '/' . 'clientpids'; if (!is_dir($cachePath)) { if (!mkdir($cachePath, 0777, true)) { throw new \RuntimeException('Cannot write in the cache folder'); } } if (null != $client) { $path = $cachePath . '/client_' . $client->getId() . '.pid'; if (!is_file($path)) { return; } Process::killProcess($path, $throwException, $this->logger, $client); } else { $iterator = new \DirectoryIterator($cachePath); foreach ($iterator as $pidFile) { if ($pidFile->isDir()) { continue; } Process::killProcess($pidFile->getRealPath(), $throwException, $this->logger); } } }
/** * {@inheritdoc} */ public function reconnect() { $this->logger->debug('Client ' . $this . ': reconnect process has been requested, kill the old process and create a new one'); Process::killProcess($this->pidPath, true, $this->logger, $this); $this->redis->del($this->getKey('invokeId')); $this->connect(); $this->authenticate(); }