Task Architecture

When creating your own task, there are some things we ought to do first. Before anything else, let’s determine whether the type of command you’d like to run really makes sense as a task.

General Console Commands vs. Tasks

  • Do you not have shell access to your Concrete site?
  • Are you uncomfortable with the command line?
  • Will you be repeatedly running this command, perhaps on a schedule?
  • Will editors less familiar with Concrete development be expected to run this command?

If the answer to these questions is Yes, then you should create a Task – because Tasks provide a simple GUI for running repeatable commands, and offer features like scheduling. If the answers to all of these is No, and you really just need to run a simple command with some output once or twice, then you might consider simply creating a console command instead. If, however, you’ve determined that you do indeed want to make a Task, read on.

Task Types

Once you determine that you do want to create a task to run the command you need, now it’s time to determine what type of task you’ll be creating. There are three types of tasks: * Tasks that run a single command immediately. These are the simplest kinds of tasks. Examples of these tasks include "Clear Cache." * Tasks that run a single command asynchronously. The command is run immediately – but the business of actually executing the command runs asynchronously whenever the task runner has the capability to do so. The task runner is triggered either by polling in the background load of the Dashboard pages, or by a dedicated command worker. Examples of tasks like these are "Generate Sitemap XML" * Tasks that create a batch of commands to run, and run them asynchronously. The same handler is used for all instances of the command, taking different parameters. Examples of commands like this include "Rescan Files" and "Reindex Content."

Our First Task

For our first task, let’s create a task based on a simple, repeatable command. "Clear Cache" is already taken – what about "Clear Log" ? Clearing the Concrete log is something you ought to do periodically, lest it get too full of entries. Furthermore, it’s not likely to be tremendously costly in terms of server resources, so we don’t have to worry too much about it requiring a separate queue worker to run. Let’s create a simple task to clear the Concrete log.