You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

If you want to set different setback counts depending on the exit code, you can use the internal API by defining an Postprocessing routine after the task.

In this sample, we define a job in a jobchain.

  • When the job ends with exih1. 1,try again in 60 seconds
  • When the job ends with exit444,try again in 2 hours
  • When the job ends with other exit codes<>0 try again in 300 seconds
  1. define a postprocessing spooler_task_after.
  2. code the switch with your requirements.
  3. add the job to a job chain. Do this even you only have one job in the chain.

XML configuration of the job

 <job order="yes"
     stop_on_error="no"
     name="job1">
    <script language="shell">
        <![CDATA[
 exit 0
        ]]>
    </script>
    <monitor name="handleSetback"
             ordering="0">
        <script language="javascript">
            <![CDATA[
 function spooler_task_after()\{
  var exit = spooler_task.exit_code;
  var job = spooler_task.job;
 
  //After one setback, handle this as an error.
  job.max_order_setbacks = 1;
 
  switch (exit ) \{
  case 0:  // proceed
    return true;
  case 1:  // Restart after 60 seconds
    job.delay_order_after_setback( 1 ) = "60";
    break;
  case 4444: //Restart after 2 hours
    job.delay_order_after_setback( 1 ) = "02:00:00";
    break;
  default: //Restart after 300 seconds
    job.delay_order_after_setback( 1 ) = "300";
    break;
  \}
  
 \}
            ]]>
        </script>
    </monitor>
    <run_time/>
 </job>

The job cain

 <job_chain orders_recoverable="yes"
           visible="yes"
           name="job_chain1">
    <job_chain_node state="100"
                    job="job1"
                    next_state="success"
                    error_state="error"
                    on_error="setback"/>
    <job_chain_node state="success"/>
    <job_chain_node state="error"/>
 </job_chain>

Sample to download

  • No labels