Prechádzať zdrojové kódy

Merge branch '2' into 'master'

Capture timeout and other error, this try and catch permit remove message from amqp.

See merge request interlink-sa/flowdat3/vendors/workflowbundle!5
Gabriel Gosparo 6 rokov pred
rodič
commit
8bd50352ac
1 zmenil súbory, kde vykonal 17 pridanie a 7 odobranie
  1. 17 7
      Services/TaskLoggerService.php

+ 17 - 7
Services/TaskLoggerService.php

@@ -97,14 +97,24 @@ class TaskLoggerService implements ConsumerInterface
     	$predir = getcwd();
     	chdir(dirname($filename));
         $process = new Process($filename);
-        $process->run();
-    	chdir($predir);
-	
-
+        try {
+            $process->run();
+    	    chdir($predir);
+    	    $output = $process->getOutput();
+            $error = $process->getErrorOutput();
+            $exit_code = $process->getExitCode();
+	    } catch (\Throwable $t) {
+	        $output = $filename . 
+	            "\n==================================ERROR==================================\n";
+            $error = "\n==================================ERROR==================================\n" .
+                $t->getMessage() . "\n" . $t->getTraceAsString() . 
+                "\n==================================ERROR==================================\n";
+            $exit_code = $t->getCode();
+        }
         return array(
-            'output' => $process->getOutput(),
-            'error' => $process->getErrorOutput(),
-            'exit_code' => $process->getExitCode(),
+            'output' => $output,
+            'error' => $error,
+            'exit_code' => $exit_code,
         );
     }