After trying some different scenarios, I think I have a solution which is not great, but works. I think the problem I was having in my BASIC code is that I was performing a DSAttachJob on the crashed job. This was causing a fatal error because it was not runnable. My code was this:
Code: Select all
JOB.NAME = 'sjob001'
hJob1 = DSAttachJob(JOB.NAME, DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: ":JOB.NAME, "JobControl")
Abort
End
ErrCode = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
IF ErrCode # DSJS.RUNNING THEN
* Setup Batch::UTILCompileJobs, run it, wait for it to finish, and test for success
hJob2 = DSAttachJob("Batch::UTILCompileJobs", DSJ.ERRFATAL)
If NOT(hJob2) Then
Call DSLogFatal("Job Attach Failed: Batch::UTILCompileJobs", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob2, "AreYouSure", "Y")
ErrCode = DSSetParam(hJob2, "Folder", "")
ErrCode = DSSetParam(hJob2, "JobsLike", JOB.NAME)
ErrCode = DSSetParam(hJob2, "NotCompiledOnly", "N")
ErrCode = DSSetParam(hJob2, "ClearLog", "N")
ErrCode = DSSetDisableProjectHandler(hJob2, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob2, @FALSE)
ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob2)
Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: Batch::UTILCompileJobs", "JobControl")
End
END
I changed it to call Batch::UTILCompileJobs unconditionally like this.
Code: Select all
JOB.NAME = 'sjob001'
* Setup Batch::UTILCompileJobs, run it, wait for it to finish, and test for success
hJob2 = DSAttachJob("Batch::UTILCompileJobs", DSJ.ERRFATAL)
If NOT(hJob2) Then
Call DSLogFatal("Job Attach Failed: Batch::UTILCompileJobs", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob2, "AreYouSure", "Y")
ErrCode = DSSetParam(hJob2, "Folder", "")
ErrCode = DSSetParam(hJob2, "JobsLike", JOB.NAME)
ErrCode = DSSetParam(hJob2, "NotCompiledOnly", "N")
ErrCode = DSSetParam(hJob2, "ClearLog", "N")
ErrCode = DSSetDisableProjectHandler(hJob2, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob2, @FALSE)
ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob2)
Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: Batch::UTILCompileJobs", "JobControl")
End
If sjob001 is running when Batch::UTILCompileJobs is called, no error will occur, so this can be run anytime. Not a great solution because this needs to be in a loop that tries to compile the job at some time interval.