Thanks for your help! I got the previous problem solved. I now have working SSH job, and I created another job where I parse data from the SSH job. It's working pretty well, but I can't seem to set the exit code for the job in javascript. The example at https://kb.sos-berlin.com/display/PKB/How+to+configure+the+handling+of+exit+codes+by+jobs uses spooler_task.set_exit_code( 0 ); but the api doesn't have that, but it has spooler_task.exit_code instead. I tried using that, but setting it seems to kill the whole order process. What's the right way to set the exit code in a job so that I can use the Job Chain controls (https://kb.sos-berlin.com/display/PKB/How+to+handle+exit+codes+in+a+job+chain) to control the flow.
I also thought that it would be pretty cool if I could put the code from my parsing job into the SSH job's postprocessing step. I created a new Pre- / Post processor, copy&pasted my code from the next job there and changed the function name to spooler_task_after(), but when I run the order/job, my I don't see anything in the logs about the postprocessing being run. I also have the configuration monitor there, so the ordering="1" on this postprocessing. Am I on the right track here, and how could I get this working? It would basically cut the amount of jobs I need in half.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For 32 bit JobScheduler releases this maps to the use of SpiderMonkey.
For 64 bit JobScheduler releases SpiderMonkey is not available.
We modified the examples in the above article to use the <script language="java:javascript"> language.
For Java versions before 1.8 this maps to the use of the scripting enginge Rhino.
For Java versions starting with 1.8 (which is required for JobScheduler releases starting from 1.9) this maps to the use of the scripting engine Nashorn.
Please consider the updated examples with changes such as
Thanks for your help! I didn't realize that changing exit code isn't enough, but I have to change the state manually too. I'm still wondering why my post processor won't fire.
This is my job:
<?xmlversion="1.0"encoding="ISO-8859-1"?><joborder="yes"stop_on_error="no"name="return test"><params/><scriptlanguage="java:javascript"><![CDATA[functionspooler_process(){spooler_log.info("Exit code 10");spooler_task.exit_code=10;varnext_state=spooler_task.order.job_chain_node.next_state;spooler_log.info("order state changed to "+next_state);spooler_task.order.state=next_state;}]]></script><monitorname="process0"ordering="0"><scriptlanguage="java:javascript"><![CDATA[functionspooler_task_after(){spooler_log.info("Exit code 5");spooler_task.exit_code=5;varnext_state=spooler_task.order.job_chain_node.next_state;spooler_log.info("order state changed to "+next_state);spooler_task.order.state=next_state;}]]></script></monitor><run_time/></job>
After running the messages from main script is run and exit code changes, but it seems like the monitor is completely ignored. I'm running this in a job chain if it has any significance.
Last edit: SOSMP 2015-08-21
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The function spooler_task_after() is executed after a task terminates.
This happens with a delay of 5s for tasks in job chains that do not run additional orders.
Additional <job idle_timeout="..." min_tasks="..."> settings can be used to prevent a task from terminating which is used in order to save the overhead of re-starting a job (and re-loading the JVM) for subsequent orders that arrive in short intervals.
The function spooler_process_after( spooler_process_result ) is executed after the order leaves the spooler_process() function. Don't forget to make this function return the value of the argument spooler_process_result or a boolean value that you calculate in the monitor script. This function might be more applicable for your case.
Best regards
Andreas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your help! I got the previous problem solved. I now have working SSH job, and I created another job where I parse data from the SSH job. It's working pretty well, but I can't seem to set the exit code for the job in javascript. The example at https://kb.sos-berlin.com/display/PKB/How+to+configure+the+handling+of+exit+codes+by+jobs uses spooler_task.set_exit_code( 0 ); but the api doesn't have that, but it has spooler_task.exit_code instead. I tried using that, but setting it seems to kill the whole order process. What's the right way to set the exit code in a job so that I can use the Job Chain controls (https://kb.sos-berlin.com/display/PKB/How+to+handle+exit+codes+in+a+job+chain) to control the flow.
I also thought that it would be pretty cool if I could put the code from my parsing job into the SSH job's postprocessing step. I created a new Pre- / Post processor, copy&pasted my code from the next job there and changed the function name to spooler_task_after(), but when I run the order/job, my I don't see anything in the logs about the postprocessing being run. I also have the configuration monitor there, so the ordering="1" on this postprocessing. Am I on the right track here, and how could I get this working? It would basically cut the amount of jobs I need in half.
HI Naranek,
sorry for the inconvenience: you were running into a compatibility problem of Java scripting engine versions.
Best regards
Andreas
Thanks for your help! I didn't realize that changing exit code isn't enough, but I have to change the state manually too. I'm still wondering why my post processor won't fire.
This is my job:
After running the messages from main script is run and exit code changes, but it seems like the monitor is completely ignored. I'm running this in a job chain if it has any significance.
Last edit: SOSMP 2015-08-21
Hi Naranek,
the functional code is fine. However, you should consider in which context this monitor script should be executed:
Best regards
Andreas