phuongdev89 / yii2-cron
Auto block|unblock console command for the Yii2. One command without duplicate.
Installs: 196
Dependents: 2
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 3
Type:yii2-extension
Requires
- php: >=7
- ext-pcntl: *
- phuongdev89/yii2-base: *
- yiisoft/yii2: 2.*
This package is auto-updated.
Last update: 2024-10-19 18:20:32 UTC
README
Provide a logic and functionality to block console commands until they execute. Unlocks commands exhibited at the expiration of the block if the server is down.
Install
composer require phuongdev89/yii2-cron
Usage
Code
Any command can be converted to daemon
class AwesomeController extends \phuongdev89\cron\commands\DaemonController { public $restartDb = false; //restart db connection every run, default is `false` public $db = 'db'; //name of db component need to restart, `db` that mean `Yii::$app->db`, default is `db` public $daemonDelay = 15; //delay time between run, in microsecond, default is `15` /** * Daemon name, unique * * @return string */ protected function daemonName(): string { return 'mail-queue'; } /** * repeatable function */ public function worker() { // Some logic that will be repeateble } }
Command
Start repeat function
php yii awesome/start
Stop repeat function
php yii awesome/stop
Restart repeat function
php yii awesome/restart
Add to crontab:
* * * * * php yii awsome/start