diff --git a/src/Ingest/IngestFlow.php b/src/Ingest/IngestFlow.php index dd6ae36..94b846a 100644 --- a/src/Ingest/IngestFlow.php +++ b/src/Ingest/IngestFlow.php @@ -8,6 +8,7 @@ use App\Entity\Document; use App\Entity\DocumentVersion; use App\Index\IndexMetaManager; use App\Knowledge\Ingest\KnowledgeIngestService; +use App\Service\LockService; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Uid\Uuid; @@ -23,10 +24,12 @@ final readonly class IngestFlow private ChunkWriteService $chunkWriteService, private VectorRebuildService $vectorRebuildService, private IndexMetaManager $metaManager, - private IngestLockService $lockService, + private LockService $lockService, private LoggerInterface $logger, private EntityManagerInterface $em, - ) {} + ) + { + } // ========================================================= // DOCUMENT INGEST @@ -84,9 +87,9 @@ final readonly class IngestFlow $this->logger->warning('Chunk count approaching limit.', [ 'existing' => $existing, 'incoming' => $incoming, - 'total' => $total, + 'total' => $total, 'document' => (string)$documentId, - 'version' => (string)$version->getId(), + 'version' => (string)$version->getId(), ]); } @@ -178,7 +181,7 @@ final readonly class IngestFlow if ($warned) { $this->logger->warning('Chunk count approaching limit after global reindex.', [ 'incoming' => $incoming, - 'total' => $incoming, + 'total' => $incoming, ]); } diff --git a/src/Ingest/IngestLockService.php b/src/Ingest/IngestLockService.php deleted file mode 100644 index 9469d71..0000000 --- a/src/Ingest/IngestLockService.php +++ /dev/null @@ -1,51 +0,0 @@ -lockFilePath = rtrim($projectDir, '/') . '/var/knowledge/locks/ingest.lock'; - } - - public function acquire(): void - { - $dir = dirname($this->lockFilePath); - - if (!is_dir($dir) && !mkdir($dir, 0777, true) && !is_dir($dir)) { - throw new \RuntimeException('Unable to create lock directory.'); - } - - $this->handle = fopen($this->lockFilePath, 'c'); - - if ($this->handle === false) { - throw new \RuntimeException('Unable to open ingest lock file.'); - } - - if (!flock($this->handle, LOCK_EX | LOCK_NB)) { - throw new \RuntimeException('Another ingest process is already running.'); - } - } - - public function release(): void - { - if ($this->handle !== null) { - flock($this->handle, LOCK_UN); - fclose($this->handle); - $this->handle = null; - } - } - - public function __destruct() - { - $this->release(); - } -} \ No newline at end of file