import { cnb } from "./common" async function runWorkspaceStart() { const startTime = Date.now(); const duration = 30 * 60 * 1000; // 30 minutes in milliseconds const interval = 5 * 60 * 1000; // 5 minutes in milliseconds let attemptCount = 0; console.log(`Starting workspace start test at ${new Date().toLocaleString()}`); console.log(`Will run every 5 minutes for 30 minutes total`); const runInterval = async () => { const currentTime = Date.now(); const elapsed = currentTime - startTime; attemptCount++; console.log(`\n=== Attempt ${attemptCount} at ${new Date().toLocaleString()} ===`); try { const start = await cnb.workspace.startWorkspace('kevisual/cnb', { branch: 'main', }); console.log(`Success: ${JSON.stringify(start, null, 2)}`); } catch (error) { console.error(`Error: ${error}`); } // Check if we should continue if (elapsed + interval < duration) { setTimeout(runInterval, interval); } else { console.log(`\nTest completed at ${new Date().toLocaleString()}`); console.log(`Total attempts: ${attemptCount}`); } }; // Set timeout to stop after 30 minutes setTimeout(() => { console.log(`\nTimeout reached at ${new Date().toLocaleString()}`); console.log(`Test terminated after 30 minutes`); }, duration); // Start the first run immediately runInterval(); } runWorkspaceStart().catch(console.error);