PHP Worker Control
Console command for maintaining worker processes., (*1)
Symfony Worker Control may be used as standalone script or included as lib to existing project., (*2)
Dependencies
- php5+ | php7+ | hhvm
- symfony/console 3+ package
- pgrep & pkill command-line utilities
Installation
Installation as lib to existing project:, (*3)
composer require nayjest/symfony-worker-control, (*4)
Installation as standalone script:, (*5)
git clone https://github.com/Nayjest/symfony-worker-control.git && cd symfony-worker-control && composer install && chmod +x workers, (*6)
Testing
Code-style (PSR2):, (*7)
1) Install code sniffer:, (*8)
composer global require "squizlabs/php_codesniffer=*", (*9)
2) Run code-style tests from symfony-worker-control folder, (*10)
composer cs, (*11)
Worker for tests:, (*12)
tests/example-worker.php, (*13)
Usage
workers [--qty QTY] [-o|--output OUTPUT] [-e|--errors ERRORS] [--] <action> <cmd>, (*14)
Command may be executed directly (./workers ...) or as argument of php command (php workers ...)., (*15)
See ./workers --help for help., (*16)
Actions
start -- start QTY processes, (*17)
restart -- stop all processes and then start QTY processes, (*18)
stop -- stop all processes, (*19)
maintain -- start QTY - N processes, where N — quantity of currently running processes., (*20)
count -- print count of running processes, (*21)
list -- print information about running processes, (*22)
Options
--qty=<value> — specifies quantity of processes to start/restart/maintain
If value isn't specified, DEFAULT_WORKER_QTY environment variable will be used.
if DEFAULT_WORKER_QTY isn't defined, qty = 1, (*23)
--output=<value> -o <value> output file for workers (STDOUT + STDERR if --errors not specified), following placeholder: {i} will be replaced to process number. Default value: /dev/null, (*24)
--errors=<value> -e <value> output file for workers (STDERR), following placeholder: {i} will be replaced to process number., (*25)
--quiet -q Do not output any message, (*26)
Help:
./workers --help, (*27)
Examples:, (*28)
./workers start --qty=2 "php my_process.php", (*29)
./workers restart --qty=3 "my_process.php", (*30)
php workers maintain --qty=4 "php my_process.php", (*31)
php workers stop "php my_process.php", (*32)
Security
If you discover any security related issues, please email mail@vitaliy.in instead of using the issue tracker., (*33)
License
© 2017—2018 Vitalii Stepanenko, (*34)
Licensed under the MIT License., (*35)
Please see License File for more information., (*36)