Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexeyshockov/symfony-signal-helper
Symfony Console helper to handle process signals
https://github.com/alexeyshockov/symfony-signal-helper
symfony symfony-console
Last synced: about 1 month ago
JSON representation
Symfony Console helper to handle process signals
- Host: GitHub
- URL: https://github.com/alexeyshockov/symfony-signal-helper
- Owner: alexeyshockov
- Created: 2015-11-11T15:48:58.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-22T11:10:55.000Z (over 5 years ago)
- Last Synced: 2024-09-17T15:58:21.580Z (about 2 months ago)
- Topics: symfony, symfony-console
- Language: PHP
- Size: 4.88 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SignalHelper
Helper for Symfony Console to handle process signals (like termination).
## Installation
```bash
$ composer require alexeyshockov/symfony-signal-helper
```## Usage
Just register the helper in your application (`app/console`, for example):
```php
#!/usr/bin/env php
getHelperSet()->set(new SignalHelper());$console->run($input);
```And use it inside your command:
```php
protected function execute(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('signal');
$helper->listen();
while (true) {
if (count(array_intersect([SIGINT, SIGTERM], $helper->takeSignals())) > 0) {
// Stop by any of SIGINT or SIGTERM.
break;
}
// Some business logic.
}
}
```