-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart-dev.js
More file actions
56 lines (49 loc) · 1.19 KB
/
start-dev.js
File metadata and controls
56 lines (49 loc) · 1.19 KB
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
53
54
55
56
const { spawn } = require('child_process');
const path = require('path');
console.log('🚀 Starting LearningLab in development mode...');
// Start the backend server
const backend = spawn('npm', ['run', 'dev'], {
cwd: path.join(__dirname, 'server'),
stdio: 'inherit',
shell: true,
env: {
...process.env,
FORCE_COLOR: '1',
NODE_ENV: 'development'
}
});
// Start the frontend dev server
const frontend = spawn('npm', ['run', 'dev'], {
cwd: path.join(__dirname, 'server/client'),
stdio: 'inherit',
shell: true,
env: {
...process.env,
FORCE_COLOR: '1',
NODE_ENV: 'development'
}
});
// Handle process termination
const handleExit = (signal) => {
console.log(`\n${signal}: Shutting down...`);
backend.kill();
frontend.kill();
process.exit();
};
process.on('SIGINT', handleExit);
process.on('SIGTERM', handleExit);
// Log process exits
backend.on('exit', (code) => {
console.log(`Backend process exited with code ${code}`);
if (code !== 0) {
frontend.kill();
process.exit(code);
}
});
frontend.on('exit', (code) => {
console.log(`Frontend process exited with code ${code}`);
if (code !== 0) {
backend.kill();
process.exit(code);
}
});