Skip to content

Commit

Permalink
Merge pull request #35 from open-runtimes/fix-dart-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldiron authored Aug 22, 2023
2 parents 4b213d8 + d8d52dc commit 2376110
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/http.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,25 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):
'key' => $secret,
]);
} catch (Throwable $th) {
$error = $th->getMessage() . $output;

// Extract as much logs as we can
try {
$logs = '';
$status = $orchestration->execute(
name: $runtimeId,
command: [ 'sh', '-c', 'cat /var/tmp/logs.txt' ],
output: $logs,
timeout: 15
);

if (!empty($logs)) {
$error = $th->getMessage() . $logs;
}
} catch(Throwable $err) {
// Ignore, use fallback error message
}

if ($remove) {
\sleep(2); // Allow time to read logs
}
Expand All @@ -541,7 +560,7 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):

$activeRuntimes->del($activeRuntimeId);

throw new Exception($th->getMessage() . $output, 500);
throw new Exception($error, 500);
}

// Container cleanup
Expand Down

0 comments on commit 2376110

Please sign in to comment.