-
Notifications
You must be signed in to change notification settings - Fork 2
How to use Tasker
If you're instructed to install and configure Tasker...
After installing the module you need to specify an execution method for tasks.
Unix Cron is the recommended way to go. It has no time limitation and it usually has less constraints than any other method. This is a fairly complex crontab entry that runs tasks in a Docker container:
*/2 * * * * docker exec --user nginx taskerdemo bash -c "cd /var/www/html/taskerdemo/site/modules/Tasker && /usr/bin/php runByCron.php"TODO describe other methods (LazyCron and JS).
If you develop a module that will use tasker...
Instead of executing a long job (e.g. creating a large number of pages during an import) you can create a task and let Tasker manage the execution.
$tasker = wire('modules')->getModule('Tasker');
$task = $tasker->createTask($class, $method, $page, 'Task title', $taskData);The specified $method of the given $class will be called by tasker to execute the job. The optional $taskData array may contain data to be passed to the $method.
Tasker will create a hidden Task page below $page and save all this data into it.
After a task is created you can activate it.
$tasker->activateTask($task);Tasker will automatically execute active tasks using one of its schedulers: Unix cron, LazyCron or TaskerAdmin's REST API + JS client.
You have to prepare your code to be called by Tasker.
See the separated Wiki page.
TaskerAdmin provides a simple GUI to list tasks and monitor their status and execution.
You can also start, stop, reset and kill tasks, or edit the task pages including their taskData array.
Your code can also check the progress, log messages and other details by reading the properties of the hidden task page.
If you have long running tasks try to use the cron-based execution method.
If your task dumps a lot of log messages then break it up into smaller ones. Appending frequently to a large log field may have huge impact on the performance.