Better stack name

This commit is contained in:
2025-06-25 14:21:22 +02:00
parent de3880e880
commit 56d94a06ce
2 changed files with 19 additions and 6 deletions

View File

@@ -499,7 +499,8 @@ async function startLaunch(data) {
`; `;
stackDeployStepElement.querySelector('.step-content').appendChild(stackProgressDiv); stackDeployStepElement.querySelector('.step-content').appendChild(stackProgressDiv);
const stackResult = await deployStack(dockerComposeResult.content, `docupulse_${data.port}`, data.port); const stackName = generateStackName(data.port);
const stackResult = await deployStack(dockerComposeResult.content, stackName, data.port);
launchReport.steps.push({ launchReport.steps.push({
step: 'Stack Deployment', step: 'Stack Deployment',
status: stackResult.success ? 'success' : 'error', status: stackResult.success ? 'success' : 'error',
@@ -530,7 +531,7 @@ async function startLaunch(data) {
// Continue with the process using the available data // Continue with the process using the available data
stackResult.data = stackResult.data || { stackResult.data = stackResult.data || {
name: `docupulse_${data.port}`, name: stackName,
status: 'creating', status: 'creating',
id: null id: null
}; };
@@ -2652,7 +2653,7 @@ async function deployStack(dockerComposeContent, stackName, port) {
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
}, },
body: JSON.stringify({ body: JSON.stringify({
name: `docupulse_${port}`, name: stackName,
StackFileContent: dockerComposeContent, StackFileContent: dockerComposeContent,
Env: [ Env: [
{ {
@@ -2727,7 +2728,7 @@ async function deployStack(dockerComposeContent, stackName, port) {
// Start polling immediately since the stack creation was initiated // Start polling immediately since the stack creation was initiated
console.log('Starting to poll for stack status after 504 timeout...'); console.log('Starting to poll for stack status after 504 timeout...');
const pollResult = await pollStackStatus(`docupulse_${port}`, 15 * 60 * 1000); // 15 minutes max const pollResult = await pollStackStatus(stackName, 15 * 60 * 1000); // 15 minutes max
return pollResult; return pollResult;
} }
@@ -2742,7 +2743,7 @@ async function deployStack(dockerComposeContent, stackName, port) {
// If stack is being created, poll for status // If stack is being created, poll for status
if (result.data.status === 'creating') { if (result.data.status === 'creating') {
console.log('Stack is being created, polling for status...'); console.log('Stack is being created, polling for status...');
const pollResult = await pollStackStatus(`docupulse_${port}`, 10 * 60 * 1000); // 10 minutes max const pollResult = await pollStackStatus(stackName, 10 * 60 * 1000); // 10 minutes max
return pollResult; return pollResult;
} }
@@ -2918,3 +2919,15 @@ async function pollStackStatus(stackName, maxWaitTime = 15 * 60 * 1000) {
} }
}; };
} }
// Helper function to generate unique stack names with timestamp
function generateStackName(port) {
const now = new Date();
const timestamp = now.getFullYear().toString() +
(now.getMonth() + 1).toString().padStart(2, '0') +
now.getDate().toString().padStart(2, '0') + '_' +
now.getHours().toString().padStart(2, '0') +
now.getMinutes().toString().padStart(2, '0') +
now.getSeconds().toString().padStart(2, '0');
return `docupulse_${port}_${timestamp}`;
}