Update launch_progress.js
This commit is contained in:
@@ -575,7 +575,11 @@ async function startLaunch(data) {
|
|||||||
// Handle different stack deployment scenarios
|
// Handle different stack deployment scenarios
|
||||||
if (!stackResult.success) {
|
if (!stackResult.success) {
|
||||||
// Check if this is a timeout but the stack might still be deploying
|
// Check if this is a timeout but the stack might still be deploying
|
||||||
if (stackResult.error && stackResult.error.includes('timed out')) {
|
if (stackResult.error && (
|
||||||
|
stackResult.error.includes('timed out') ||
|
||||||
|
stackResult.error.includes('504 Gateway Time-out') ||
|
||||||
|
stackResult.error.includes('504 Gateway Timeout')
|
||||||
|
)) {
|
||||||
console.log('Stack deployment timed out, but may still be in progress');
|
console.log('Stack deployment timed out, but may still be in progress');
|
||||||
|
|
||||||
// Update the step to show warning instead of error
|
// Update the step to show warning instead of error
|
||||||
@@ -2938,6 +2942,11 @@ async function deployStack(dockerComposeContent, stackName, port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First, attempt to deploy the stack
|
// First, attempt to deploy the stack
|
||||||
|
console.log('Making stack deployment request to /api/admin/deploy-stack');
|
||||||
|
console.log('Stack name:', stackName);
|
||||||
|
console.log('Port:', port);
|
||||||
|
console.log('Modified docker-compose content length:', modifiedDockerComposeContent.length);
|
||||||
|
|
||||||
const response = await fetch('/api/admin/deploy-stack', {
|
const response = await fetch('/api/admin/deploy-stack', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -3005,6 +3014,10 @@ async function deployStack(dockerComposeContent, stackName, port) {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('Response status:', response.status);
|
||||||
|
console.log('Response ok:', response.ok);
|
||||||
|
console.log('Response headers:', Object.fromEntries(response.headers.entries()));
|
||||||
|
|
||||||
// Handle 504 Gateway Timeout as successful initiation
|
// Handle 504 Gateway Timeout as successful initiation
|
||||||
if (response.status === 504) {
|
if (response.status === 504) {
|
||||||
console.log('Received 504 Gateway Timeout - stack creation may still be in progress');
|
console.log('Received 504 Gateway Timeout - stack creation may still be in progress');
|
||||||
@@ -3026,13 +3039,18 @@ async function deployStack(dockerComposeContent, stackName, port) {
|
|||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
let errorMessage = 'Failed to deploy stack';
|
let errorMessage = 'Failed to deploy stack';
|
||||||
|
console.log('Response not ok, status:', response.status);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const errorData = await response.json();
|
const errorData = await response.json();
|
||||||
errorMessage = errorData.error || errorMessage;
|
errorMessage = errorData.error || errorMessage;
|
||||||
|
console.log('Parsed error data:', errorData);
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
|
console.log('Failed to parse JSON error, trying text:', parseError);
|
||||||
// If JSON parsing fails, try to get text content
|
// If JSON parsing fails, try to get text content
|
||||||
try {
|
try {
|
||||||
const errorText = await response.text();
|
const errorText = await response.text();
|
||||||
|
console.log('Error text content:', errorText);
|
||||||
if (errorText.includes('504 Gateway Time-out') || errorText.includes('504 Gateway Timeout')) {
|
if (errorText.includes('504 Gateway Time-out') || errorText.includes('504 Gateway Timeout')) {
|
||||||
console.log('Received 504 Gateway Timeout - stack creation may still be in progress');
|
console.log('Received 504 Gateway Timeout - stack creation may still be in progress');
|
||||||
|
|
||||||
@@ -3053,9 +3071,11 @@ async function deployStack(dockerComposeContent, stackName, port) {
|
|||||||
errorMessage = `HTTP ${response.status}: ${errorText}`;
|
errorMessage = `HTTP ${response.status}: ${errorText}`;
|
||||||
}
|
}
|
||||||
} catch (textError) {
|
} catch (textError) {
|
||||||
|
console.log('Failed to get error text:', textError);
|
||||||
errorMessage = `HTTP ${response.status}: Failed to parse response`;
|
errorMessage = `HTTP ${response.status}: Failed to parse response`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log('Throwing error:', errorMessage);
|
||||||
throw new Error(errorMessage);
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3077,6 +3097,30 @@ async function deployStack(dockerComposeContent, stackName, port) {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deploying stack:', error);
|
console.error('Error deploying stack:', error);
|
||||||
|
|
||||||
|
// Check if this is a 504 timeout error that should be handled as a success
|
||||||
|
if (error.message && (
|
||||||
|
error.message.includes('504 Gateway Time-out') ||
|
||||||
|
error.message.includes('504 Gateway Timeout') ||
|
||||||
|
error.message.includes('timed out')
|
||||||
|
)) {
|
||||||
|
console.log('Detected 504 timeout in catch block - treating as successful initiation');
|
||||||
|
|
||||||
|
// Update progress to show that we're now polling
|
||||||
|
const progressBar = document.getElementById('launchProgress');
|
||||||
|
const progressText = document.getElementById('stepDescription');
|
||||||
|
if (progressBar && progressText) {
|
||||||
|
progressBar.style.width = '25%';
|
||||||
|
progressBar.textContent = '25%';
|
||||||
|
progressText.textContent = 'Stack creation initiated (timed out, but continuing to monitor)...';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start polling immediately since the stack creation was initiated
|
||||||
|
console.log('Starting to poll for stack status after 504 timeout from catch block...');
|
||||||
|
const pollResult = await pollStackStatus(stackName, 15 * 60 * 1000); // 15 minutes max
|
||||||
|
return pollResult;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: error.message
|
error: error.message
|
||||||
|
|||||||
Reference in New Issue
Block a user