adt / command-lock
Locks the command against multiple triggering
Installs: 8 626
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 5
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- ext-posix: *
- adt/utils: ^2.10
- symfony/console: ^4.0|^5.0|^6.0|^7.0
README
namespace App\Commands; use ADT\CommandLock\CommandLock; use ADT\CommandLock\Storage\FileSystemStorage; use Exception; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; abstract class Command extends \Symfony\Component\Console\Command\Command { use CommandLock; private string $locksDir; abstract protected function executeCommand(InputInterface $input, OutputInterface $output): int; public function setLocksDir(string $locksDir) { $this->locksDir = $locksDir; } /** * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $this->setStorage(new FileSystemStorage($this->locksDir)); $this->lock(); $status = $this->executeCommand($input, $output); $this->unlock(); return $status; } }