FreePBX / issue-tracker

The unified FreePBX issue tracker.
https://www.freepbx.org
GNU General Public License v3.0
7 stars 1 forks source link

[bug]: Framework: Single Job failure makes all jobs after not run #11

Closed jfinstrom closed 6 months ago

jfinstrom commented 6 months ago

FreePBX Version

FreePBX 16

Issue Description

As mentioned by @kguptasangoma in https://github.com/FreePBX/certman/pull/4#issuecomment-1938045993 it seems that an exception on any Job running will kill the whole process. This can be easily fixed by wrapping the individual task in the job runner. Example:

private function runJobs($jobs = []) {
    // ... (Existing code) ...

    foreach($jobs as $config) {

        // ... (Existing code within the loop) ...

        try { 
           // ... (Job execution logic) ... 
        } catch (\Exception $e) {
            $msg = "<error> ". sprintf(_("Error in the task %s Exception = %s"),$config['job'],$e->getMessage())." </error>";
            $this->writelog($msg);

            // Optionally, you might want to add specific failure handling or 
            // retry logic for the individual job here.
        }
    }

    // ... (Rest of the function) ...
}

Operating Environment

All versions FreePBX 15+

Relevant log output

No response

kguptasangoma commented 6 months ago

Hi @jfinstrom We have pushed the code which will continue with the next job run irrespective of currently running job status. Ref- https://github.com/FreePBX/framework/commit/709bfbf5d0a60b91d8f64819d5f5cc0953221534