title: sos berlin scheduler -- job chain - how to trigger other job after job timeout
body: <p>I'm using sos berlin scheduler (version linux-x64 1.10.5).</p>
  
  <p>Normally when job in job_chain timeout, scheduler will kill the job process and send a email.
  So, based on this, I want to trigger other job. 
  But, I have tried two ways all doesn't work.</p>
  
  <p><strong><em>Way 1:</em></strong></p>
  
  <p>Add a function “spooler_task_after()” in the job.</p>
  
  <p>I guess the failure is because this job will create a process on linux system, while job timeout scheduler kill this job process, also kill the function “spooler_task_after()”</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;job timeout="00:00:09"&gt;
      &lt;script language="shell"&gt;&lt;![CDATA[
  
      echo aa
      sleep 10s
      echo bb
  
      ]]&gt;&lt;/script&gt;
      &lt;monitor name="exit_code" ordering="0"&gt;
      &lt;script language="java:javascript"&gt;&lt;![CDATA[
  
      function spooler_task_after(){
         var exitCode = spooler_task.exit_code;
         spooler_log.info ("Exit Code is: " + exitCode);
  
         /*
          call other job
         */
  
         result = true;
        return result;
      }
  
              ]]&gt;&lt;/script&gt;
      &lt;/monitor&gt;
      &lt;run_time/&gt;
  &lt;/job&gt;
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>2017-07-27 21:22:21.251+0800 [info]   
  2017-07-27 21:22:21.251+0800 [info]   Task sample_errorhandling/job1:23026 - Protocol starts in /httx/opt/sos-scheduler/ldw-scheduler-test1/logs/task.sample_errorhandling,job1.log
  2017-07-27 21:22:21.250+0800 [info]   SCHEDULER-842  Task is going to process Order sample_errorhandling/job_chain3:12, state=aaa, on JobScheduler 'http://xxxx:4444', Order's Process_class
  2017-07-27 21:22:21.268+0800 [info]   SCHEDULER-726  Task runs on this JobScheduler 'http://jt-host-kvm-72:4444'
  2017-07-27 21:22:21.268+0800 [info]   SCHEDULER-918  state=starting (at=never)
  2017-07-27 21:22:22.466+0800 [info]   SCHEDULER-987  Starting process: '/bin/sh' '-c' '"/tmp/admin/sos.gBdCm8"'
  2017-07-27 21:22:23.520+0800 [info]   [stdout] aa
  2017-07-27 21:22:30.326+0800 [ERROR]  SCHEDULER-272  Terminating task after reaching deadline &lt;job timeout="9"&gt;
  2017-07-27 21:22:30.359+0800 [ERROR]  SCHEDULER-202  Connection to task has been lost, state=running_remote_process: Z-REMOTE-101  Separate process: pid=0: Connection lost / zschimmer::com::object_server::Connection::pop_operation
  2017-07-27 21:22:30.359+0800 [ERROR]  SCHEDULER-202  Connection to task has been lost, state=release: Z-REMOTE-122  Separate process pid=0: Caller has killed process
  2017-07-27 21:22:30.384+0800 [ERROR]  SCHEDULER-280  Process terminated with exit code 1 (0x63)
  2017-07-27 21:22:30.384+0800 [WARN]   SCHEDULER-845  Task ended without processing the order. The order remains in job's order queue in the same state
  2017-07-27 21:22:30.384+0800 [info]   SCHEDULER-843  Task has ended processing of Order sample_errorhandling/job_chain3:12, state=aaa, on JobScheduler 'http:/xxxx:4444'
  </code></pre>
  
  <p><strong><em>Way 2:</em></strong></p>
  
  <p>Add return code on job chain node</p>
  
  <p>This way works on job execute successfully or with error. But failed when job was killed with timeout.</p>
  
  <p>Code in job chain:</p>
  
  <pre><code>&lt;job_chain &gt;
      &lt;job_chain_node  state="aaa" job="job1" next_state="success" error_state="error"&gt;
          &lt;on_return_codes &gt;
              &lt;on_return_code  return_code="1"&gt;
                  &lt;add_order  xmlns="https://jobscheduler-plugins.sos-berlin.com/NodeOrderPlugin" job_chain="/error_handling/sendmail"/&gt;
              &lt;/on_return_code&gt;
          &lt;/on_return_codes&gt;
      &lt;/job_chain_node&gt;
  
      &lt;job_chain_node  state="success"/&gt;
  
      &lt;job_chain_node  state="error"/&gt;
  &lt;/job_chain&gt;
  </code></pre>