Running tasks is straightforward process of defining the task, and then launching instances of this task as needed (or scheduling instances to run a number of times). The main advantage of using the SRE2002 task manager, as opposed to a CRON like system utility, is that tasks can be easily launched by daemons, or by web based scripts.
Tasks can be any REXX program, or any executable that can be invoked by a REXX program. When one launches a task, you can provide it an argument (of any length).
The task manager also has resource utilization management capabilities. You can limit the number of tasks that can be running simultaneously, the lifespan of a task, and the frequency with which tasks can be launched. This control can be exercised on families of tasks, whose members can be freely defined.
Although flexible, the task manager has a sequential nature, which means that sometimes tasks will be queued up. Thus, the task manager should not be used to perform real-time resolution of web requests. However, it can be used to produce outputs (say, by a script that uses arguments provided via an html form) that can be delivered to the client at a later date.
For example, this can be as simple as saving a file in a web-accessible location, so that a client can (after a suitably long coffee break) request this output using a predetermined URL (one that points to this web-accessibe location). Alternatively, a client may (after a suitable wait) query an "output manager" script that will return the appropriate output (say, as indexed by the client's username).
To use the task manager, we strongly recommend using the SRE_TASK procedure. Basically, there are several types of actions supported by SRE_TASK:
DEFAULT_MAX_TASK=5 |
The maximum number of simultaneous tasks that can be run simultaneously,
defined across a family of tasks.
Example: DEFAULT_MAX_TASK=6 |
DEFAULT_MAX_LIFESPAN | The default maximum lifespan of a task (in seconds), defined across a family
of tasks.
Example: DEFAULT_MAX_LIFESPAN=1200 |
DEFAULT_MIN_WAIT | The default minimum wait, in seconds, between launching tasks within the
same family. 0 means "no limit". In other words, you can't launch
a task until this many seconds have elapsed since the last task belonging
to this family was launched.
Example: DEFAULT_MIN_WAIT=0 |
ACTION | The action to take. Four actions are recognized:
|
NAME | NAME is a task name or a family name. The task name can also include
a family name.
|
CONTROLS | CONTROLS is optional control information. |
DATA | DATA is used to pass ACTION specific parameters.
|
OWNID | OWNID is strictly optional. It should be the "own id" of the calling procedure (say, as created with the SRE_DMN_OWN procedure). If an OWNID one is not available, SRE_TASK will create one. |
astat will be a status message, or an error
message. Error messages have the form: error error-message |
Action = FAMILY |
Families are used to group tasks together, both as a means
of specifying default parameters, and as a means of limiting
the number of tasks that can be run. It is okay to define
a family that will contain only one task.
CONTROLS may contain a comma seperated list of family specific
limits:
Notes on CONTROLS:
With FAMILY, the DATA parameter is ignored.
Notes on the return value:
Action = DEFINE
|
DEFINE is used to associate
a taskname with a file. When defining a taskname, use the
.FAMILY to assign the taskname to a family.
|
CONTROLS can be used to remove an already defined taskname.
DATA should be fully qualified filename of the REXX program of this task. Note: the return value from the DEFINE action of SRE_TASK is either:
Action=LAUNCH
| Launch a task, using NAME to select a task-name (that has
been defined using a prior DEFINE call). Remember to include
a .FAMILY_NAME if needed.
| Two CONTROLS parameters are recognized:
DATA is information that will be sent to the REXX program/procedure
when it is launched. The program can read this using: The structure of the DATA is of no concern to the task manager -- it is up to the procedure requesting the task, and the task, to determine how to pass information effectively. Note: the return value from the LAUNCH action is a status message: For example: Launched TASK_15 as SRE_TASK_107_1 Scheduled: T3.F1 Pending on min_wait Pending on max_task Launched TASK_16 as SRE_TASK_107_2 Scheduled: T2In the Launched returns, the first word identifies the daemon-id of this instance of the task, the second word is the macrospace procedure containing the REXX code for this task.
Action = STATS
|
Return statistics on defined families, defined tasks,
active tasks, scheduled tasks, and pending tasks.
| A simple set of HTML tables is returned. You can send these to a client using SRE_COMMAND('VAR ...') Examples of SRE_TASK
|
a REXX procedures that is loaded into macrospace, and called as an external procedureAs with other external procedures, the first line must be a REXX comment (
Tasks will be passed two argument --
When complete, tasks should return with a value of 1. Actually, it doesn't matter what they return -- SRE2002 does not pay attention to what is returned by tasks. However, they should return , rather then exit.
Notes:
Alternatively, to run your task a number of times over a defined period, you can use the SCHEDULE argument when launching a task.