Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kaliop/kaliop-lock-command-bundle
https://github.com/kaliop/kaliop-lock-command-bundle
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kaliop/kaliop-lock-command-bundle
- Owner: kaliop
- Created: 2017-11-08T16:13:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-10T08:52:38.000Z (over 6 years ago)
- Last Synced: 2024-11-16T00:18:43.095Z (2 months ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kaliop Lock Command Bundle
## Installation
### Configure repository
```bash
$ php composer.phar config repositories.kaliopConsoleBundle '{ "type": "vcs", "url": "https://github.com/kaliop/kaliop-lock-command-bundle.git" }'
```### Install bundle
```bash
$ php composer.phar require kaliop/lock-command-bundle
```### Add bundle to the Symfony kernel
```php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
...
new Kaliop\LockCommandBundle\LockCommandBundle(),
...
];
}
}
```### Remove bundle
```bash
$ php composer.phar remove kaliop/lock-command-bundle
```## Usage
### Command locker
This bundle gives the possibility to "lock" console commands in order to prevent concurrent execution.
In order to do so, you have to declare your command as a service and tag it with `lock: true`
```yml
services:
test.console.command:
class: AppBundle\Command\TestLockCommand
tags:
- { name: "console.command", lock: true }
```As you can see, the `console.command` tag has available a new lock option, which can be set to either `true` or `false`.
Commands registered with the lock option set to `true` will be locked at the command start event and unlocked at the command terminate or exception event.Additionally, if needed, you can pass a `--no-lock` option on the command line when launching a command if you don't want the command to be locked for a single execution:
```bash
$ php bin/console kaliop:command:example --no-lock
```