承接 helhum/typo3-crontab 相关项目开发

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

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

helhum/typo3-crontab

Composer 安装命令:

composer require helhum/typo3-crontab

包简介

Advanced scheduling for TYPO3 Console commands and TYPO3 Scheduler tasks

README 文档

README

Disclaimer

This package is made with the intention to, at some point, replace the current functionality of TYPO3 scheduler extension. It is in early development stage, which means that not all features (especially UI wise) are implemented yet, but the implemented functionality is known to work reliably. This package currently does not work in Windows environments, as no POSIX functions (posix_getpgid) are available, which are required to check whether the processes are actually running.

Key features

  • Tasks are configured via configuration, thus are deployable as code.
  • In addition to regular Scheduler tasks, any TYPO3 Console command and any shell script can be added as task.
  • Whether a task is shown as running in the UI, always reflects the real state of the process. No more marking tasks not running in case they crash with an error.
  • Stopping a task via the UI actually stops the process, instead of just marking it as not running.
  • The crontab command (crontab:run) to execute the scheduled tasks can optionally be a long running process, constantly looking for tasks to be executed (the option --timeout) and allows parallel execution of of different due tasks (the option --forks).
  • Tasks can be configured to be re-scheduled for immediate execution in case they failed.

Installation

  1. Add the extension to your TYPO3 Project: composer require helhum/typo3-crontab
  2. Configure the system cron to run the command: /path/to/vendor/bin/typo3cms crontab:run
  3. Configure tasks in your TYPO3 configuration file(s)

Configuring schedules for commands (and scheduler tasks)

Configuring schedules it purely done through configuration (aka. TYPO3_CONF_VARS), typically in LocalConfiguration.php or AdditionalConfiguration.php

This means:

  1. Extensions could add tasks as well (through ext_localconf.php files)
  2. It is possible to add different tasks in different environments (by providing different configuration for different environments)
  3. Deploy same tasks in all environments

Example (in yaml notation):

EXTCONF:
    crontab:
        update_refindex:
            group: 'Demo'
            multiple: false
            retryOnFailure: false
            title: 'Updates reference index'
            cron: '*/30 * * * *'
            process:
                type: command
                command: cleanup:updatereferenceindex
                arguments:
                    - '--quiet'
                    - '--no-interaction'
        shell_script:
            group: 'Demo'
            multiple: false
            retryOnFailure: true
            title: 'Executing a shell script'
            description: 'Path relative to composer root or absolute'
            cron: '*/12 * * * *'
            process:
                type: script
                script: res/scripts/test.sh
                arguments:
                    - 'foo'
        php_script:
            group: 'Demo'
            multiple: false
            retryOnFailure: false
            title: 'Executing a php script'
            description: '"@php" placeholder can be used to reference the PHP binary used by the crontab:run command'
            cron: '*/42 * * * *'
            process:
                type: script
                script: '@php res/scripts/test.php'
                arguments:
                    - 'bar'
        test:
            group: 'Demo'
            multiple: true
            retryOnFailure: false
            description: 'Just for demo purposes'
            cron: '*/1 * * * *'
            process:
                type: scheduler
                className: TYPO3\CMS\Scheduler\Example\TestTask
                arguments:
                    email: test@test.test
        solr_indexer:
            group: 'Demo'
            multiple: false
            retryOnFailure: false
            description: 'Run early, run often'
            cron: '*/5 * * * *'
            process:
                type: scheduler
                className: ApacheSolrForTypo3\Solr\Task\IndexQueueWorkerTask
                arguments:
                    site: 1
                    documentsToIndexLimit: 20
                    forcedWebRoot: null

Current state

  • There is no user interface for adding tasks or removing tasks. You have to provide the configuration manually.
  • TYPO3 Console is a hard requirement
  • The extension only comes for Composer installations. TYPO3 in non Composer mode is not supported.
  • start times, end times for scheduled tasks do not exist. If you have such requirement,
  • The command to execute scheduled tasks is crontab:run you could build some automation around the crontab:schedule command to automate enabling/disabling tasks at appropriate times.

Concepts (especially in relation to TYPO3 scheduler)

Everything is a command or script

The main purpose of this extension is to execute different units of work as background task on a regular schedule. Similar to Unix crontab, a unit of work is limited to be a TYPO3 Console command or shell script. To provide backwards compatibility, Scheduler tasks are wrapped into a special command, so that they can be used as unit of work, too. So every command that is available as command in TYPO3 Console and every shell script, will be a valid unit of work to be scheduled. Whether it makes sense to do schedule certain commands, is up to you to decide.

Just a crontab

Just like with a Unix crontab, there is no possibility for defining start or end time or for setting a unit of work to only execute once.

It is possible to configure commands to be scheduled, but remove them from regular scheduled executions. Similar to adding commands to your crontab but commenting them out, so that they are ignored.

Such commands will appear in the UI as "disabled". On first deployment on a target system all configured commands are disabled and must be enabled to be scheduled, either through the UI, or by using the crontab:schedule command.

Security considerations

Since conceptually it is possible to execute any TYPO3 Console command, it becomes pretty clear, users with access to this module must be considered to have access to the complete TYPO3 installation (system maintainer) and to an extent also to the underlying OS. Just similar to having access to extension manager (which allows integrating PHP code) or install tool (where you can create admin users).

Contribution

Every contribution is valuable. Please check it out and test it, give feedback by creating feature requests or suggestions, create pull requests with change suggestions, reach out to me via Twitter or any other channel.

helhum/typo3-crontab 适用场景与选型建议

helhum/typo3-crontab 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44.64k 次下载、GitHub Stars 达 33, 最近一次更新时间为 2018 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 helhum/typo3-crontab 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 44.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 33
  • 点击次数: 27
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 33
  • Watchers: 13
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2018-11-28