Задача: Команда должна выполняться лишь в одном экземпляре. Например, это может быть обработка выгрузки внешней системы. Ранее требовалось подключать и вызывать symfony/lock компонент. Ныне есть удобный трейт: https://symfony.com/doc/current/console/lockable_trait.html `#[AsCommand(name: 'contents:update')] class UpdateContentsCommand { use LockableTrait;

public function __invoke(SymfonyStyle $io): int { if (!$this->lock()) { $io->writeln('The command is already running in another process.');

return Command::SUCCESS; }

// If you prefer to wait until the lock is released, use this: // $this->lock(null, true);

// ...

// if not released explicitly, Symfony releases the lock // automatically when the execution of the command ends $this->release();

return Command::SUCCESS; } }`