ElevAIt / scripts /start.js
Mahdi Naser Moghadasi
Claude Opus 4.5
Add GitHub sync daemon to push logs to mahdinaser/brightmind repo
96fdde4
Raw History Blame Contribute Delete
1.2 kB
/**
* Start script for ElevAIt
* Runs both the Next.js server and the GitHub sync daemon
*/
const { spawn } = require('child_process');
const path = require('path');
console.log('πŸš€ Starting ElevAIt...');
// Start the GitHub sync daemon
const daemonPath = path.join(__dirname, 'github-sync-daemon.js');
const daemon = spawn('node', [daemonPath], {
stdio: 'inherit',
env: process.env
});
daemon.on('error', (err) => {
console.error('❌ Failed to start sync daemon:', err.message);
});
// Start the Next.js server
const server = spawn('node', ['server.js'], {
stdio: 'inherit',
env: process.env,
cwd: process.cwd()
});
server.on('error', (err) => {
console.error('❌ Failed to start Next.js server:', err.message);
process.exit(1);
});
server.on('exit', (code) => {
console.log(`Next.js server exited with code ${code}`);
daemon.kill();
process.exit(code);
});
// Handle shutdown
process.on('SIGTERM', () => {
console.log('πŸ›‘ Received SIGTERM, shutting down...');
daemon.kill('SIGTERM');
server.kill('SIGTERM');
});
process.on('SIGINT', () => {
console.log('πŸ›‘ Received SIGINT, shutting down...');
daemon.kill('SIGINT');
server.kill('SIGINT');
});