Spaces:
Paused
Paused
File size: 1,200 Bytes
96fdde4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | /**
* 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');
});
|