phuongdev89/yii2-cron
Composer 安装命令:
composer require phuongdev89/yii2-cron
包简介
Auto block|unblock console command for the Yii2. One command without duplicate.
README 文档
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
统计信息
- 总下载量: 215
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-10