X-Git-Url: http://git.annexia.org/?p=whenjobs.git;a=blobdiff_plain;f=tools%2Fwhenjobs.pod;h=b8c76a6c6637f2a8c4bc319032ce4bf864234225;hp=2958eba7d88dd1b75981b884dc9f0658598b5010;hb=545581eb916ac5f020295b59458e16af51ea6cc5;hpb=f35f462b83f860958da38347d30b45986b8f4774 diff --git a/tools/whenjobs.pod b/tools/whenjobs.pod index 2958eba..b8c76a6 100644 --- a/tools/whenjobs.pod +++ b/tools/whenjobs.pod @@ -548,7 +548,7 @@ environment variable. As well as simple "every" and "when" expressions, advanced users may want to use arbitrary OCaml expressions, functions, etc in the jobs script. These are useful for factoring common code or strings, for -setting the initial values of variables, or for defining cleanup +setting the initial values of variables, or for defining pre and post functions. A simple example of an OCaml expression is: @@ -582,7 +582,7 @@ reloaded. Variables are created when they are referenced, and until set they have the value empty string (just like the shell). Across file -reloads, the previous values of variables is preserved. +reloads, the previous values of variables are preserved. To initialize a variable to a known value when the jobs file is loaded, call one of the C functions as in @@ -592,23 +592,23 @@ this example: Whentools.set_variable "name" "Richard"; Whentools.set_variable_int "counter" 0 -=head3 CLEANUP FUNCTIONS +=head3 POST FUNCTIONS After a job runs, you can control what happens to its output by -writing a cleanup function. To write a cleanup function you have to -name the job (ie. have an explicit C statement). Put C +writing a C function. To write a post function you have to +name the job (ie. have an explicit C statement). Put C after the job name like this: job "poll source" - cleanup (Whentools.mailto "you@example.com") + post (Whentools.mailto "you@example.com") every 10 seconds : << # ... >> -A number of cleanup functions are available in the library; see below. +A number of post functions are available in the library; see below. -You can also write your own cleanup functions (in OCaml). The +You can also write your own post functions (in OCaml). The function is passed one argument which is a C struct, defined below. @@ -621,7 +621,8 @@ defined below. =item B [I<~only_on_failure:true>] [I<~from:from_address>] I I -Send the result of the script by email to the given email address. +This built-in post function sends the result of the script by email to +the given email address. If the optional C<~only_on_failure:true> flag is set, then it is only sent out if the script failed. @@ -635,15 +636,15 @@ do not need to add it. Here are some examples of using the mailto function: job "ex.1" - cleanup (Whentools.mailto "you@example.com") + post (Whentools.mailto "you@example.com") every 10 seconds : << # do something >> job "ex.2" - cleanup (Whentools.mailto ~only_on_failure:true - "you@example.com") + post (Whentools.mailto ~only_on_failure:true + "you@example.com") every 10 seconds : << # do something @@ -653,7 +654,7 @@ Here are some examples of using the mailto function: let to_addr = "you@example.com" job "ex.3" - cleanup (Whentools.mailto ~from to_addr) + post (Whentools.mailto ~from to_addr) every 10 seconds : << # do something @@ -688,7 +689,7 @@ Set variable I to the floating point value I. =item B -This structure is passed to cleanup functions. It has the following +This structure is passed to post functions. It has the following fields: type result = {