承接 adiafora/laravel-cron-schedule 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adiafora/laravel-cron-schedule

Composer 安装命令:

composer require adiafora/laravel-cron-schedule

包简介

The ability to run the Laravel task scheduler using different crons

README 文档

README

Laravel Task Scheduling is a great way to manage the cron. But the documentation contains the following warning:

By default, multiple tasks scheduled at the same time will execute sequentially based on the order they are defined in your schedule method. If you have long-running tasks, this may cause subsequent tasks to start much later than anticipated.

The runInBackground() method can help you. But!

The runInBackground method may only be used when scheduling tasks via the command and exec methods.

What should I do if I use code instead of running commands?..

Using our package, you can run as many cron as you want on the server, specifying its name for each one. And in the App\Console\Kernel you can specify which cron should handle this task in the onCron() method. A сron launched without specifying a name will be considered a default cron. You don't need to specify anything to put a task in this cron.

Install

Run:

    composer require adiafora/laravel-cron-schedule

Usage

App\Console\Kernel

In the App\Console\Kernel, replace the line:

    use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

with this:

    use Adiafora\Schedule\Kernel as ConsoleKernel;

Server

Now delete the cron entry on your server:

 * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

And add an entry instead:

 * * * * * cd /path-to-your-project && php artisan cron-schedule:run >> /dev/null 2>&1

Your scheduler is working now as before.

Another cron

You can add another cron to your server by specifying its name using the option --cron=. Let's give it a name longTime:

 * * * * * cd /path-to-your-project && php artisan cron-schedule:run --cron=longTime >> /dev/null 2>&1

And now you can specify the name of this cron for any task in the scheduler.

    $schedule->call(function () {
        $this->mailService->send();
        sleep(60);
        $this->mailService->send(true);
    })
        ->onCron('longTime')
        ->dailyAt('03:00');

    $schedule->call(function () {
        $this->report->prepare();
    })
        ->dailyAt('03:00');

Note that the task of preparing the report will work exactly at 03:00, without waiting for the emails sending! This way you can create as many crones as you want, give them names and assign tasks to them, distributing them as you see fit. And in each cron, the task will be launched strictly at the specified time, without waiting for other tasks launched at the same time in other crones.

License

The MIT License (MIT). Please see License File for more information.

adiafora/laravel-cron-schedule 适用场景与选型建议

adiafora/laravel-cron-schedule 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 4, 最近一次更新时间为 2022 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cron」 「schedule」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 adiafora/laravel-cron-schedule 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 adiafora/laravel-cron-schedule 我们能提供哪些服务?
定制开发 / 二次开发

基于 adiafora/laravel-cron-schedule 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 43
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-24