#!/usr/bin/env node

/**
 * forever-sleep.js
 * A script that sleeps, wakes up every 5 seconds, logs to stdout, then goes back to sleep.
 */

const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));

async function main() {
  console.log('forever-sleep: Starting...');
  
  while (true) {
    const timestamp = new Date().toISOString();
    console.log(`forever-sleep: ${timestamp} - Waking up (sleeping for 5 seconds)...`);
    
    await sleep(5000);
    
    const timestampAfter = new Date().toISOString();
    console.log(`forever-sleep: ${timestampAfter} - Back to sleep...`);
  }
}

main().catch(err => {
  console.error('forever-sleep: Error:', err);
  process.exit(1);
});
