const fs = require('fs'); const tokenData = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/token.json', 'utf8')); const DOMAIN_A = 'tcp-echo-server-42b5404df3a2.hosted.ghaymah.systems'; const DOMAIN_B = 'tcp-test-client-002b2b09325b.hosted.ghaymah.systems'; async function checkStatus() { const res = await fetch('https://graphql.ghaymah.systems/v1/graphql', { method: 'POST', headers: { 'Authorization': 'Bearer ' + tokenData.token, 'Content-Type': 'application/json' }, body: JSON.stringify({ query: `query { ghaymah_cloud_resources(where: { id: { _in: ["af1b9e91-9bec-4d6a-b76c-92d7273b82ce", "fcbd895c-2370-46db-bd6a-057f6d887b0f"] } }) { id status message updated_at values } }` }) }); const data = await res.json(); return data.data?.ghaymah_cloud_resources || []; } async function main() { console.log('Monitoring deployment progress...'); for (let i = 1; i <= 20; i++) { console.log(`\n--- Poll attempt ${i} (${new Date().toLocaleTimeString()}) ---`); const apps = await checkStatus(); for (const app of apps) { console.log(`[${app.values?.name}] status: ${app.status} | msg: ${app.message} | updated: ${app.updated_at}`); } // Also test HTTP let readyA = false, readyB = false; try { const resA = await fetch(`https://${DOMAIN_A}/health`, { signal: AbortSignal.timeout(4000) }); const textA = await resA.text(); console.log(`App A HTTP (${resA.status}): ${textA.substring(0, 100)}`); if (resA.status === 200) readyA = true; } catch (e) { console.log(`App A HTTP: ${e.message}`); } try { const resB = await fetch(`https://${DOMAIN_B}/health`, { signal: AbortSignal.timeout(4000) }); const textB = await resB.text(); console.log(`App B HTTP (${resB.status}): ${textB.substring(0, 100)}`); if (resB.status === 200) readyB = true; } catch (e) { console.log(`App B HTTP: ${e.message}`); } if (readyA && readyB) { console.log('\nšŸŽ‰ BOTH APPS ARE DEPLOYED AND HEALTHY ON GHAYMAH!'); return; } await new Promise(r => setTimeout(r, 10000)); } } main().catch(console.error);