承接 pantheon-systems/terminus-scheduled-jobs-plugin 相关项目开发

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

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

pantheon-systems/terminus-scheduled-jobs-plugin

Composer 安装命令:

composer require pantheon-systems/terminus-scheduled-jobs-plugin

包简介

Configure and manage scheduled jobs via Terminus commands.

README 文档

README

Scheduled Jobs

This plugin allows scheduling jobs on the Pantheon platform. Due to the private beta status, the feature is only enabled upon request on a site by site basis. Each job runs in its own container with access to both the database and distributed file system. For now, other features such as access to the New Relic agent or secure integration are not available.

Installation

The only requirement is terminus itself, version 3.x or 4.x. To install the plugin, the current repository needs to be cloned locally, followed by the execution of the following command:

terminus self:plugin:install $PATH_TO_LOCAL_CLONE

Job Schedules

Job schedules are characterized as job definitions which allow setting a name for each job, a command and schedule in the UNIX cron format (https://en.wikipedia.org/wiki/Cron).

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │                                   7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * <command to execute>

Creating a new schedule

Creating a new schedule can be performed running the command below. The given example runs an hourly job executing Drupal cron:

terminus scheduledjobs:schedule:create $SITE_NAME.$ENVIRONMENT "test-scheduled-job-hourly" "drush -vvv cron" "0 * * * *"

Listing schedules

terminus scheduledjobs:schedule:list $SITE_NAME.$ENVIRONMENT

-------------------------------------- --------------------------- ------------- ---------------------------------- --------- ----------------------
 ID                                     Name                        Schedule      Command                            Status    Created At (UTC)
-------------------------------------- --------------------------- ------------- ---------------------------------- --------- ----------------------
 d178dd16-b0e3-47dc-a446-1bf4343f7fff   test-scheduled-job-hourly   0 * * * *     ls -la /files && drush -vvv cron   ENABLED   2023-05-19T07:34:26Z
-------------------------------------- --------------------------- ------------- ---------------------------------- --------- ----------------------

Pausing / resuming schedules

At any point, job executions can either be paused or resumed.

terminus scheduledjobs:schedule:pause $SITE_NAME.$ENVIRONMENT $SCHEDULE_ID
terminus scheduledjobs:schedule:resume $SITE_NAME.$ENVIRONMENT $SCHEDULE_ID

Deleting schedules

terminus scheduledjobs:schedule:delete $SITE_NAME.$ENVIRONMENT $SCHEDULE_ID

Jobs

Jobs are defined as individual executions associated with a certain schedule. Listing jobs involves obtaining the schedule id.

terminus scheduledjobs:job:list $SITE_NAME.$ENVIRONMENT $SCHEDULE_ID

-------------------------------------- ------------------------------- ------------------------------- ---------
 ID                                     Start Time                      End Time                        Status
-------------------------------------- ------------------------------- ------------------------------- ---------
 ca93e729-58e8-489f-805b-f73d4102c5c0   2023-05-26 07:00:03 +0000 UTC   2023-05-26 07:01:57 +0000 UTC   SUCCESS
 808a3a84-b1c6-42cf-92c8-f0b6afe959c8   2023-05-26 06:00:03 +0000 UTC   2023-05-26 06:01:51 +0000 UTC   SUCCESS
 e0a74a62-6705-4f0c-830c-0190f57dc1c0   2023-05-26 05:00:00 +0000 UTC   2023-05-26 05:01:34 +0000 UTC   SUCCESS
 7effda3b-be2e-42b9-9093-cd373b7b3079   2023-05-26 04:00:00 +0000 UTC   2023-05-26 04:01:33 +0000 UTC   SUCCESS
 54c39e63-fcf5-41f0-81ec-4163fc1f498b   2023-05-26 03:00:00 +0000 UTC   2023-05-26 03:01:54 +0000 UTC   SUCCESS
 fdf2cf55-88f5-44a1-8a7e-d422291f625a   2023-05-26 02:00:02 +0000 UTC   2023-05-26 02:01:51 +0000 UTC   SUCCESS
-------------------------------------- ------------------------------- ------------------------------- ---------

Logs

Viewing logs associated with jobs is possible by passing the job ID to the command below:

terminus scheduledjobs:job:logs $SITE_NAME.$ENVIRONMENT $JOB_ID

Quotas and further considerations

The private beta nature of this feature comes with a quota defined at the site level as a daily runtime budget.

Job Budget

Each site has a fixed allocated budget of 18000 seconds (300 minutes) per day measured by the second. This is calculated as the sum of all job durations, from the moment the job has started until it finished. There are currently no restrictions around the number of schedules that can be created for any given site. If the daily budget is exhausted, running jobs are given a 15 minute grace period after which a timeout signal will be issued. No other jobs will be created that day until midnight UTC when all budgets are reset. In calculating the budget, partial minutes are rounded up.

terminus scheduledjobs:budget:info $SITE_NAME.$ENVIRONMENT

---------------------- ------------------------ -----------
 Daily Budget Elapsed   Daily Budget Remaining   Resets In
---------------------- ------------------------ -----------
 0s                     18000s                   6h31m3s
---------------------- ------------------------ -----------

Job Timeout

Timeouts are dynamic and dependent on the remaining budget plus a grace period. For instance, the daily available budget at the start of the day is 300 minutes, which means the first job's timeout is 315 minutes. When a job is launched throughout the day and the remaining budget is 60 minutes, the timeout will be calculated to 75 minutes.

Email

Sending email via sendmail or localhost SMTP is not permitted. Email can still be sent via integrations with third party email providers either via their SMTP servers or API integrations.

pantheon-systems/terminus-scheduled-jobs-plugin 适用场景与选型建议

pantheon-systems/terminus-scheduled-jobs-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 571 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 07 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 pantheon-systems/terminus-scheduled-jobs-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 21
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-18