boehsermoe/luya-module-scheduler
Composer 安装命令:
composer require boehsermoe/luya-module-scheduler
包简介
The LUYA Scheduler module.
README 文档
README
Installation
composer require boehsermoe/luya-module-scheduler:"~1.0.0"
In order to add the modules to your project go into the modules section of your config:
return [ 'modules' => [ // ... 'scheduleradmin' => [ 'class' => 'luya\scheduler\admin\Module', ], 'scheduler' => [ 'class' => 'luya\scheduler\frontend\Module', 'accessToken' => '{token for web access}' // optional for webcron ], // ... ], ];
./vendor/bin/luya migrate ./vendor/bin/luya import
Don`t forget to assign permission to user group for the scheduler module.
Start jobs manuell via CLI
Start all expired jobs manual:
./luya scheduler/run
Execute specified job:
./luya scheduler/run/now {id/name of the job}
Trigger jobs by cron
Start all expired jobs every minute via cron:
* * * * * ./luya scheduler/run
Trigger jobs alternativ
Via Webcron
Call the route https://{Host}/scheduler/run?token={Access token from config} to start expired jobs. You can use this url for webcrons like https://cron-job.org/de/ or https://uptimerobot.com/. Or any other webcron service.
Via yii application event
[
...
'on afterRequest' => function() {
if (!$this->isCli()) {
Yii::$app->getModule('scheduler')->runExpiredJobsAsync();
}
},
...
]
CommandJob: Execute console commands
For example you can flush the cache every hour by add a new CommandJob (Scheduler -> CommandJobs -> Add) and insert "cache/flush-all" as command. The command is the route of the console command.
Custom Jobs
You can also write your own jobs classes in the path "{appBasePath}/schedulers" or "{moduleBasePath}/schedulers". Every job have to inherite from BaseJob.
class ExampleJob extends \luya\scheduler\models\BaseJob { public function run() { // Do your job. } }
A job with a text field as option could look like this:
class ExampleTextJob extends \luya\scheduler\models\BaseJob { public $text; public function rules() { return array_merge(parent::rules(), [ [['text'], 'required'] ]); } public function extraFields() { return [ 'text' ]; } public function ngrestExtraAttributeTypes() { return [ 'text' => 'text', ]; } public function run() { // Do your job // // echo $this->text; } }
More examples
For file backups: https://github.com/boehsermoe/luya-module-backup/blob/master/src/schedules/FileBackupJob.php
For database backups: https://github.com/boehsermoe/luya-module-backup/blob/master/src/schedules/DatanbaseBackupJob.php
boehsermoe/luya-module-scheduler 适用场景与选型建议
boehsermoe/luya-module-scheduler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 559 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「module」 「backup」 「yii」 「yii2」 「luya」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 boehsermoe/luya-module-scheduler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 boehsermoe/luya-module-scheduler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 boehsermoe/luya-module-scheduler 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
A simple database backup manager for Symfony2 with support for S3, Rackspace, Dropbox, FTP, SFTP.
Fix failed Craft backups and restores with full paths to psql, mysql, and mysqldump executables.
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Yii2 module to manage website content. Kind of a CMS...
统计信息
- 总下载量: 559
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-17
