Flow Framework Task Scheduler

Related tags

Task Runners task
Overview

Flow Framework Task Scheduler

This package provides a simple to use task scheduler for Neos Flow. Tasks are configured via settings, recurring tasks can be configured using cron syntax. Detailed options configure the first and last executions as well as options for the class handling the task.

Scheduling and running tasks are decoupled: The Scheduler schedules tasks whcih the are executed by the TaskRunner. This architecture allows receiving and displaying metrics of already executed tasks.

Most of the architectural ideas behind the package are taken from php-task, and reimplemented for Neos Flow.

Installation

composer require 'flowpack/task'

Configuration

Defining A Task

Flowpack:
  Task:
    tasks:
      'a-unique-identifier':
        label: The label of this task
        description: Some detailed description of thsi task
        # A class, implementing the TaskHandlerInterface  
        handlerClass: 'Vendor\Package\TaskHandler\TaskHandlerClass'
        cronExpression: '*/5 * * * *'
        # A workload, eg. some configuration, given to the taskHandler
        workload:
          interval: PT5M

General Options

lockStorage: Configuration string for the lock storage used for taksHandler implementing LockingTaskHandlerInterface. See https://symfony.com/doc/current/components/lock.html#available-stores for more options

Implementing A Task Handler

A task handler contains the code executed for a specific task. Your command handler has to implement one of the following interfaces:

Flowpack\Task\TaskHandler\TaskHandlerInterface

A basic task. The interface requires the method handle(WorkloadInterface $workload): string to be implemented. The return value serves as information for successfully executed tasks.

Flowpack\Task\TaskHandler\RetryTaskHandlerInterface

Also requires getMaximumAttempts(): int to be implemented. Allowing the tasks to be retried on failure.

Flowpack\Task\TaskHandler\LockingTaskHandlerInterface

Also requires getLockIdentifier(WorkloadInterface $workload): string to be implemented. The return value specifies a lock to be acquired. When such a task is running, other tasks requiring the same lock will be skipped.

Available Commands

Show a list of all defined and scheduled tasks:

./flow task:list

Show details about a specific task:

./flow task:show <taskIdentifier>
Comments
  • TASK: added SQlite migration

    TASK: added SQlite migration

    I want to use this package for a project not using a database. Since the task's are written to some doctrine repository I added a sqlite migration.

    With a configuration like

    Neos:
      Flow:
        persistence:
          backendOptions:
            driver: 'pdo_sqlite'
            # in memory database
            #path: ':memory:'
            path: '%FLOW_PATH_DATA%Persistent/db.sqlite'
    

    this package can now be used in simpler NEOS/Flow project

    opened by gjwnc 3
  • BUGFIX: Prevent permanent lock

    BUGFIX: Prevent permanent lock

    Without this change: all tasks will be locked and skipped from running, as soon as you configure a lock storage and implement the LockingTaskHandlerInterface

    With this change: The return value is handled as intended/expected when a lock is acquired (symfony/lock acquire returns true upon successfull lock aquire, false upon lock conflict)

    opened by riea 0
  • BUGFIX: Improve stability slightly and fix tests

    BUGFIX: Improve stability slightly and fix tests

    This change mostly tweaks some cosmetics, fixes a broken functional test and improves the UX of the commands a bit:

    • Prevent null pointer exceptions in TaskCommandController and provide error message if a given task id does not exist
    • Fix TaskRunner::reFetchExecution() that had no effect previously
    • Fix type hints
    • Fix Flowpack\Task\Tests\Functional\Domain\Repository\TaskExecutionRepositoryTest::findNext that is broken since version 0.1.0

    Fixes: #5

    opened by bwaidelich 0
  • Order of scheduled tasks wrong?

    Order of scheduled tasks wrong?

    While skimming through the code base I found out that the functional tests fail with the current version:

    There was 1 failure:
    
    1) Flowpack\Task\Tests\Functional\Domain\Repository\TaskExecutionRepositoryTest::findNext
    First one should be taskTwo
    Failed asserting that two strings are equal.
    --- Expected
    +++ Actual
    @@ @@
    -'taskTwo'
    +'taskOne'
    

    I could track it back to Commit aedf7f848df444e02139763e1eb88a085c6d0986 that changed

    ->orderBy('taskExecution.scheduleTime', QueryInterface::ORDER_ASCENDING)
    

    to

    ->orderBy('taskExecution.scheduleTime', QueryInterface::ORDER_DESCENDING)
    

    AFAIS the test has to be adjusted

    bug 
    opened by bwaidelich 0
  • BUG: Exceptions can be null but the get Method requires a string

    BUG: Exceptions can be null but the get Method requires a string

    The exception property of the TaskExecution class can be null but the get and set methods are requiring a string.

        /**
         * @var string
         * @ORM\Column(nullable = true, type = "text")  //<--- Null is allowed
         */
        protected $exception;
    
        /**
         * @return string
         */
        public function getException(): string // <--- returns only a string
        {
            return $this->exception;
        }
    
        /**
         * @param string $exception
         * @return TaskExecution
         */
        public function setException(string $exception): TaskExecution
        {
            $this->exception = $exception;
            return $this;
        }
    

    If you call the method ./flow task:sho <identifier> it is not possible to get a list of the runned tasks: image

    opened by erkenes 0
  • TASK: TaskExecutionHistory removes non existing task handlers

    TASK: TaskExecutionHistory removes non existing task handlers

    During TaskExecutionHistory::cleanup() DB entries are removed if the task handlers in the DB is not configured or doesn't exist anymore.
    This behaviour can be configured by the setting keepRemovedTasksInTaskExecutionHistory which by default keeps the current behaviour and doesn't remove entries.

    This PR is about auto cleanup of the TaskExecutionHistory if one removes a task from the configuration or a handlerClass is renamed. Old entries are then automatically removed if enabled.

    opened by gjwnc 0
  • TASK: TaskCollectionFactory ignores non existing configured handlerCass

    TASK: TaskCollectionFactory ignores non existing configured handlerCass

    I just had the case, that an invalid handleClass was written into the DB and had to remove it manually from there. With this PR, a configured tasks is checked with class_exists and if it doesn't exist, the this task is ignored and an info message is written to the system log.

    opened by gjwnc 1
  • task:runsingle <task identifier> runs all due tasks

    task:runsingle runs all due tasks

    Current behavior: task:runsingle runs all due tasks instead of only the one specified by the <task identifier>

    Expected behavior: task:runsingle runs only the task specified by the <task identifier>, if task execution is due

    opened by riea 0
  • Missleading naming

    Missleading naming "run*"

    I got confused by the names of the two run* commands because I expected them to, well, run the tasks but in fact even ./flow task:runSingle only schedules a task – or even doesn't do anything if one is scheduled already.

    (PS: I copied the naming to my TaskModule package which makes it even more confusing)

    Suggestion

    I propose to deprecate the two commands task:run and task:runSingle in favor of a new command task:schedule (or similar) with an optional filter to schedule tasks by id etc. (task:run and task:runSingle should still work of course for B/C but they would be hidden from ./flow help)

    Additionally I could imagine another command task:execute that allows to immediately run a task whether it is scheduled or not.

    @daniellienert I could take care of this suggestion, but would like to hear your opinion on it, first

    enhancement 
    opened by bwaidelich 2
Releases(1.2.0)
  • 1.2.0(Oct 18, 2022)

    What's Changed

    • FEATURE: PostgreSQL migration by @bwaidelich in https://github.com/Flowpack/task/pull/16
    • TASK: Add automatic tests via github action by @daniellienert in https://github.com/Flowpack/task/pull/7
    • TASK: fix typos, add missing codeblocks by @crydotsnake in https://github.com/Flowpack/task/pull/14
    • TASK: added SQlite migration by @gjwnc in https://github.com/Flowpack/task/pull/12
    • Task: Typo fixes by @gjwnc in https://github.com/Flowpack/task/pull/10
    • BUGFIX: Prevent permanent lock by @riea in https://github.com/Flowpack/task/pull/17
    • BUGFIX: Improve stability slightly and fix tests by @bwaidelich in https://github.com/Flowpack/task/pull/6

    New Contributors

    • @bwaidelich made their first contribution in https://github.com/Flowpack/task/pull/6
    • @crydotsnake made their first contribution in https://github.com/Flowpack/task/pull/14
    • @gjwnc made their first contribution in https://github.com/Flowpack/task/pull/12
    • @riea made their first contribution in https://github.com/Flowpack/task/pull/17

    Full Changelog: https://github.com/Flowpack/task/compare/1.1.1...1.2.0

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Nov 18, 2021)

  • 1.1.0(Oct 28, 2021)

    What's Changed

    • FEATURE: Improve task show command with detailed history by @daniellienert in https://github.com/Flowpack/task/pull/3

    Full Changelog: https://github.com/Flowpack/task/compare/1.0.1...1.1.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Sep 26, 2021)

  • 1.0.0(Sep 17, 2021)

  • 0.1.0(Aug 3, 2021)

Owner
Flowpack
Flowpack
Laravel Cron Scheduling - The ability to run the Laravel task scheduler using different crons

Laravel Cron Scheduling Laravel Task Scheduling is a great way to manage the cron. But the documentation contains the following warning: By default, m

Sergey Zhidkov 4 Sep 9, 2022
PHP cron job scheduler

PHP Cron Scheduler This is a framework agnostic cron jobs scheduler that can be easily integrated with your project or run as a standalone command sch

Giuseppe Occhipinti 698 Jan 1, 2023
:date: Easy!Appointments - Open Source Appointment Scheduler

Easy!Appointments A powerful Open Source Appointment Scheduler that can be installed on your server. About • Features • Setup • Installation • License

Alex Tselegidis 2.5k Jan 8, 2023
Cronlike scheduler running inside a ReactPHP Event Loop

Cronlike scheduler running inside a ReactPHP Event Loop Install To install via Composer, use the command below, it will automatically detect the lates

Cees-Jan Kiewiet 35 Jul 12, 2022
A PHP-based job scheduler

Crunz Install a cron job once and for all, manage the rest from the code. Crunz is a framework-agnostic package to schedule periodic tasks (cron jobs)

null 58 Dec 26, 2022
Modern task runner for PHP

RoboTask Modern and simple PHP task runner inspired by Gulp and Rake aimed to automate common tasks: writing cross-platform scripts processing assets

Consolidation 2.6k Jan 3, 2023
Awesome Task Runner

Bldr Simplified Build System/Task Runner Uses Yaml, JSON, XML, PHP, or INI for configs Quick Usage To develop, run ./script/bootstrap, and then ./scri

null 223 Nov 20, 2022
Pure PHP task runner

task/task Got a PHP project? Heard of Grunt and Gulp but don't use NodeJS? Task is a pure PHP task runner. Leverage PHP as a scripting language, and a

null 184 Sep 28, 2022
Modern task runner for PHP

RoboTask Modern and simple PHP task runner inspired by Gulp and Rake aimed to automate common tasks: writing cross-platform scripts processing assets

Consolidation 2.6k Dec 28, 2022
🐺 Asynchronous Task Queue Based on Distributed Message Passing for PHP.

?? Asynchronous Task Queue Based on Distributed Message Passing for PHP.

Ahmed 36 Aug 11, 2022
A versatile and lightweight PHP task runner, designed with simplicity in mind.

Blend A versatile and lightweight PHP task runner, designed with simplicity in mind. Table of Contents About Blend Installation Config Examples API Ch

Marwan Al-Soltany 42 Sep 29, 2022
A PHP implementation of a bare task loop.

TaskLoop A PHP implementation of a bare task loop. Installation. $ composer require thenlabs/task-loop 1.0.x-dev Usage. The file example.php contains

ThenLabs 1 Oct 17, 2022
Manage your Laravel Task Scheduling in a friendly interface and save schedules to the database.

Documentation This librarian creates a route(default: /schedule) in your application where it is possible to manage which schedules will be executed a

Roberson Faria 256 Dec 21, 2022
Task Scheduling with Cron Job in Laravel

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Shariful Islam 1 Oct 16, 2021
Laravel-Tasks is a Complete Build of Laravel 5.2 with Individual User Task Lists

An app of tasks lists for each individual user. Built on Laravel 5.2, using 5.2 authentication and middleware. This has robust verbose examples using Laravel best practices.

Jeremy Kenedy 26 Aug 27, 2022
Modern and simple PHP task runner inspired by Gulp and Rake aimed to automate common tasks

RoboTask Modern and simple PHP task runner inspired by Gulp and Rake aimed to automate common tasks: writing cross-platform scripts processing assets

Consolidation 2.6k Jan 3, 2023
Reset the live preset for debug settings with a task

Debug Settings Task This TYPO3 extension resets TYPO3 debug settings to the »live« preset on production using a scheduler task. Vision “Better safe th

webit! Gesellschaft für neue Medien mbH 1 Aug 15, 2022
Crunz is a framework-agnostic package to schedule periodic tasks (cron jobs) in PHP using a fluent API.

Crunz Install a cron job once and for all, manage the rest from the code. Crunz is a framework-agnostic package to schedule periodic tasks (cron jobs)

Reza Lavarian 1.4k Dec 26, 2022
xcron - the souped up, modernized cron/Task Scheduler for Windows, Mac OSX, Linux, and FreeBSD server and desktop operating systems.

xcron is the souped up, modernized cron/Task Scheduler for Windows, Mac OSX, Linux, and FreeBSD server and desktop operating systems. MIT or LGPL.

CubicleSoft 7 Nov 30, 2022
Laravel Cron Scheduling - The ability to run the Laravel task scheduler using different crons

Laravel Cron Scheduling Laravel Task Scheduling is a great way to manage the cron. But the documentation contains the following warning: By default, m

Sergey Zhidkov 4 Sep 9, 2022