-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-app.js
More file actions
69 lines (54 loc) · 2.11 KB
/
start-app.js
File metadata and controls
69 lines (54 loc) · 2.11 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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env node
/**
* Startup script for LangGPT Prompt Assistant
* Runs both the MCP backend server and frontend server
*/
import { spawn } from 'child_process';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('🚀 Starting LangGPT Prompt Assistant...\n');
// Function to start a process
function startProcess(command, args, name, color) {
const process = spawn(command, args, {
stdio: 'pipe',
shell: true,
cwd: __dirname
});
process.stdout.on('data', (data) => {
console.log(`[${color}${name}\x1b[0m] ${data.toString().trim()}`);
});
process.stderr.on('data', (data) => {
console.error(`[${color}${name}\x1b[0m] ERROR: ${data.toString().trim()}`);
});
process.on('close', (code) => {
console.log(`[${color}${name}\x1b[0m] Process exited with code ${code}`);
});
return process;
}
// Start MCP backend server
console.log('📡 Starting MCP backend server...');
const backendProcess = startProcess('npm', ['run', 'dev'], 'BACKEND', '\x1b[36m');
// Wait a bit for backend to start, then start frontend
setTimeout(() => {
console.log('🌐 Starting frontend server...');
const frontendProcess = startProcess('node', ['frontend-server.js'], 'FRONTEND', '\x1b[32m');
// Handle shutdown
process.on('SIGINT', () => {
console.log('\n🛑 Shutting down servers...');
backendProcess.kill('SIGINT');
frontendProcess.kill('SIGINT');
process.exit(0);
});
process.on('SIGTERM', () => {
console.log('\n🛑 Shutting down servers...');
backendProcess.kill('SIGTERM');
frontendProcess.kill('SIGTERM');
process.exit(0);
});
}, 2000);
console.log('\n✅ Servers starting up...');
console.log('📱 Frontend will be available at: http://localhost:8080');
console.log('🔗 MCP backend will be available at: http://localhost:3000');
console.log('⏹️ Press Ctrl+C to stop all servers\n');