const { spawn } = require('child_process'); | |
const path = require('path'); | |
console.log('🚀 Starting Luna OCR Development Environment...\n'); | |
// Start backend server | |
console.log('📡 Starting backend server...'); | |
const backend = spawn('npm', ['start'], { | |
cwd: path.join(__dirname, 'server'), | |
stdio: 'inherit', | |
shell: true | |
}); | |
// Wait a bit for backend to start | |
setTimeout(() => { | |
console.log('\n🎨 Starting frontend...'); | |
const frontend = spawn('npm', ['start'], { | |
stdio: 'inherit', | |
shell: true | |
}); | |
// Handle process termination | |
process.on('SIGINT', () => { | |
console.log('\n🛑 Shutting down...'); | |
backend.kill(); | |
frontend.kill(); | |
process.exit(); | |
}); | |
frontend.on('close', (code) => { | |
console.log(`Frontend exited with code ${code}`); | |
backend.kill(); | |
}); | |
backend.on('close', (code) => { | |
console.log(`Backend exited with code ${code}`); | |
frontend.kill(); | |
}); | |
}, 2000); | |
backend.on('close', (code) => { | |
console.log(`Backend exited with code ${code}`); | |
}); |