Workflows

Workflows are small helpers, scheduled to run at a certain time or in a certain situation. In addition, workflows may represent both: Job that are executed only once, e.g. a task-reminder, triggered at the due-date. Or they may represent jobs that'll be executed over and over again.

The lifecylce of a single job is represented by three states:

  • NEW: The job was created, so the workflow-handler was instantiated.

  • SCHEDULED: As soon as the workflow-engine finds a job marked as NEW, it triggers the job in order to schedule itself. This means, the transition from NEW to SCHEDULED is nearly the same as asking the job to calculate the date of the next execution.

  • EXECUTED: The job reached its trigger date and was executed by the workflow-engine. As soon as a job was executed, it may be reset to either SCHEDULED – the job will be triggered once more – or EXECUTED, reaching the end of the jobs lifecycle.

Before the engine executes a single workflow, the instance is marked as “locked”. This avoids that the task is executed twice (e.g. since your workflow takes a long time to run and the trigger is called again in the meantime).

Settings

In order to execute workflows, the engine has to be triggered in a regular interval. This ensures, that the engine is able to pick up new or scheduled jobs.

Since PHP itself has no cron-like mechanisms, the workflow-module provides an URL that should be called in a regular interval, e.g. by using a cron-job.

The URL is build like following:

http://path_to_your_kajona_installation/xml.php?module=workflows&action=trigger

For security reasons you have to provide a secret when calling the trigger. Otherwise, third-party users would be able to trigger the workflow-engine, causing more system-load then necessary.

Therefore the setting „Auth-Key“ is used to store the secret. By default, the secret is initialized during the modules' installation with a 20-char random string. Attach it to the URL in order to trigger the workflows successfully:

`http://path_to_your_kajona_installation/xml.php?module=workflows&action=trigger&authkey=YOURSECRET

If the authkey matches the one of your installation, new or overdue job will be triggered, otherwise the engine will deny access.

If you have a UNIX machine, you could trigger the workflows using cron and wget:

*/5 * * * * wget -O /dev/null  'http://path_to_your_kajona_installation/xml.php?module=workflows&action=trigger&authkey=YOURSECRET' > /dev/null 2>&1

This would trigger the workflow-engine every 5 minutes by calling the script. The result is ignored and saved to /dev/null.

https://raw.githubusercontent.com/kajona/kajonacms/master/module_workflows/docs/manual_workflows_en.md
No comments made till now
Fork me on GitHub