Skip to content

Commit 35c784b

Browse files
authored
Merge pull request #3203 from ProcessMaker/bugfix/3167
Truncate docker output log and display more info
2 parents b4b4afe + 95dfb2d commit 35c784b

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

ProcessMaker/Models/ScriptDockerBindingFilesTrait.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ private function runContainer($image, $command, $parameters, $bindings, $timeout
8686
);
8787
}
8888
Log::error('Script threw return code ' . $returnCode . 'Message: ' . implode("\n", $output));
89-
throw new ScriptException(implode("\n", $output));
89+
90+
$message = implode("\n", $output);
91+
$message .= "\n\nProcessMaker Stack:\n";
92+
$message .= (new \Exception)->getTraceAsString();
93+
throw new ScriptException($message);
9094
}
9195
$outputs = $this->getOutputFilesContent();
9296
$this->removeTemporalFiles();

ProcessMaker/Models/ScriptDockerCopyingFilesTrait.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Log;
66
use RuntimeException;
77
use ProcessMaker\Exception\ScriptTimeoutException;
8+
use ProcessMaker\Exception\ScriptException;
89

910
/**
1011
* Execute a docker container copying files to interchange information.
@@ -51,7 +52,7 @@ private function createContainer($image, $command, $parameters = '')
5152
{
5253
$cidfile = tempnam(config('app.processmaker_scripts_home'), 'cid');
5354
unlink($cidfile);
54-
$cmd = config('app.processmaker_scripts_docker') . sprintf(' create %s --cidfile %s %s %s 2>&1', $parameters, $cidfile, $image, $command);
55+
$cmd = config('app.processmaker_scripts_docker') . sprintf(' create --network=host %s --cidfile %s %s %s 2>&1', $parameters, $cidfile, $image, $command);
5556
$line = exec($cmd, $output, $returnCode);
5657
if ($returnCode) {
5758
throw new RuntimeException('Unable to create a docker container: ' . implode("\n", $output));
@@ -150,7 +151,10 @@ private function startContainer($container, $timeout)
150151
throw new ScriptTimeoutException(implode("\n", $output));
151152
}
152153
Log::error('Script threw return code ' . $returnCode);
153-
throw new ScriptException(implode("\n", $output));
154+
$message = implode("\n", $output);
155+
$message .= "\n\nProcessMaker Stack:\n";
156+
$message .= (new \Exception)->getTraceAsString();
157+
throw new ScriptException($message);
154158
}
155159
return compact('line', 'output', 'returnCode');
156160
}

ProcessMaker/ScriptRunners/Base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function run($code, array $data, array $config, $timeout, ?User $user)
115115
$returnCode = $response['returnCode'];
116116
$stdOutput = $response['output'];
117117
$output = $response['outputs']['response'];
118-
\Log::debug("Docker returned: " . json_encode($response));
118+
\Log::debug("Docker returned: " . substr(json_encode($response), 0, 500));
119119
if ($returnCode || $stdOutput) {
120120
// Has an error code
121121
throw new RuntimeException(implode("\n", $stdOutput));

tests/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@
9494
Artisan::call('migrate:fresh', []);
9595
}
9696

97-
if (count(ScriptExecutor::listOfExecutorImages('php')) === 0) {
97+
if (ScriptExecutor::where('language', 'php')->count() === 0) {
9898
Artisan::call('docker-executor-php:install');
9999
}
100100

101-
if (count(ScriptExecutor::listOfExecutorImages('lua')) === 0) {
101+
if (ScriptExecutor::where('language', 'lua')->count() === 0) {
102102
Artisan::call('docker-executor-lua:install');
103103
}

0 commit comments

Comments
 (0)