Fix ssr separation; add edge debugging logs

This commit is contained in:
Matej Bačo 2025-06-24 15:56:06 +02:00
parent 5dcc508870
commit b5bc240c0d

View file

@ -747,6 +747,13 @@ class Builds extends Action
if ($separator !== false) { if ($separator !== false) {
$logs = \substr($logs, 0, $separator); $logs = \substr($logs, 0, $separator);
$insideSeparation = true; $insideSeparation = true;
$leftover = \substr($logs, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR_START}'));
$separator = \strpos($leftover, '{APPWRITE_DETECTION_SEPARATOR_END}');
if ($separator !== false) {
$logs .= \substr($leftover, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR_END}'));
$insideSeparation = false;
}
} }
} else { } else {
$separator = \strpos($logs, '{APPWRITE_DETECTION_SEPARATOR_END}'); $separator = \strpos($logs, '{APPWRITE_DETECTION_SEPARATOR_END}');
@ -836,11 +843,10 @@ class Builds extends Action
// Separate logs for SSR detection // Separate logs for SSR detection
$detectionLogs = ''; $detectionLogs = '';
$separator = \strpos($logs, '{APPWRITE_DETECTION_SEPARATOR_START}'); if (\str_contains($logs, '{APPWRITE_DETECTION_SEPARATOR_START}')) {
if ($separator !== false) {
[$logsBefore, $detectionLogsStart] = \explode('{APPWRITE_DETECTION_SEPARATOR_START}', $logs, 2); [$logsBefore, $detectionLogsStart] = \explode('{APPWRITE_DETECTION_SEPARATOR_START}', $logs, 2);
[$detectionLogs, $logsAfter] = \explode('{APPWRITE_DETECTION_SEPARATOR_END}', $detectionLogsStart, 2); [$detectionLogs, $logsAfter] = \explode('{APPWRITE_DETECTION_SEPARATOR_END}', $detectionLogsStart, 2);
$logs = $logsBefore . $logsAfter; $logs = ($logsBefore ?? '') . ($logsAfter ?? '');
} }
$deployment->setAttribute('buildLogs', $logs); $deployment->setAttribute('buildLogs', $logs);
@ -877,6 +883,10 @@ class Builds extends Action
$this->afterBuildSuccess($queueForRealtime, $dbForProject, $deployment); $this->afterBuildSuccess($queueForRealtime, $dbForProject, $deployment);
\var_dump("After edge finish:");
\var_dump($deployment);
\var_dump('---');
if ($resource->getCollection() === 'sites') { if ($resource->getCollection() === 'sites') {
$date = \date('H:i:s'); $date = \date('H:i:s');
$logs .= "[$date] [appwrite] Screenshot capturing started. \n"; $logs .= "[$date] [appwrite] Screenshot capturing started. \n";
@ -1225,12 +1235,8 @@ class Builds extends Action
$message = "" . $message; $message = "" . $message;
} }
$separator = \strpos($message, '{APPWRITE_DETECTION_SEPARATOR_START}'); $message = \str_replace('{APPWRITE_DETECTION_SEPARATOR_START}', '', $message, 1);
if ($separator !== false) { $message = \str_replace('{APPWRITE_DETECTION_SEPARATOR_END}', '', $message, 1);
$error = \substr($message, $separator + strlen('{APPWRITE_DETECTION_SEPARATOR_START}'));
$message = \substr($message, 0, $separator);
$message .= "\n" . $error;
}
// Combine with previous logs if deployment got past build process // Combine with previous logs if deployment got past build process
$previousLogs = ''; $previousLogs = '';