After the first stable release about three months ago. PHP-Task was introduced in the Sulu ecosystem by including it into the SuluAutomationBundle and so it was used by a few projects in production.
Now I am ready to release the second Release and here are the new features in detail.
Lock Component
In one of this projects, we implemented a handler which takes a lot of time. The need to lock other handlers was born.
This feature (see php-task/php-task#35 and documentation) was implemented with BC in mind, so I introduced a new interface "LockingTaskHandlerInterface". Handlers which implements this interface are able to specify a lock-key for a given "workload". This key will be used as an identifier for the lock item.
Example: If your handler returns the class name of the handler then all the executions with this handler are locked during the execution.
The lock only encroaches if the cronjobs overlap because of long-running handlers.
To enable this feature simply add the following configuration in the Symfony config of your project:
task:
locking:
enabled: true
System Tasks
Another feature which was requested by a real world project was the System-Tasks feature (see php-task/TaskBundle#38 and documentation). In this specific project, we have implemented TaskHandler's which have to run on a specific time each day, week and month to calculate statistics.
To be sure that this tasks will be scheduled (and updated) in the deployment we have implemented the system-tasks.
task:
system_tasks:
my_task:
enabled: true
handler_class: 'AppBundle\Handler\TestHandler'
workload: 'my workload'
interval: '@daily'
To schedule, these tasks run the following command.
bin/console task:schedule:system-tasks
Update
You can update the library and the bundle by running following commands. The first command updates the composer dependencies and the second updates the database.
composer update php-task/php-task php-task/task-bundle
bin/console doctrine:schema:update
Now you can use the new features. Stay tuned for the upcoming things.