-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-zuplo.js
More file actions
114 lines (96 loc) · 3.76 KB
/
start-zuplo.js
File metadata and controls
114 lines (96 loc) · 3.76 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env node
const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');
console.log('🚀 Starting Zuplo API Management Platform...\n');
// Check if dependencies are installed
const checkDependencies = () => {
const mainNodeModules = path.join(__dirname, 'node_modules');
const adminNodeModules = path.join(__dirname, 'admin-dashboard', 'node_modules');
if (!fs.existsSync(mainNodeModules)) {
console.log('❌ Main dependencies not found. Please run: npm install');
process.exit(1);
}
if (!fs.existsSync(adminNodeModules)) {
console.log('❌ Admin dashboard dependencies not found. Please run: cd admin-dashboard && npm install');
process.exit(1);
}
console.log('✅ Dependencies check passed');
};
// Check environment file
const checkEnvironment = () => {
const envFile = path.join(__dirname, '.env');
if (!fs.existsSync(envFile)) {
console.log('⚠️ .env file not found. Creating from template...');
const envExample = path.join(__dirname, '.env.example');
if (fs.existsSync(envExample)) {
fs.copyFileSync(envExample, envFile);
console.log('✅ .env file created from template');
} else {
console.log('❌ .env.example not found. Please create .env manually');
}
} else {
console.log('✅ Environment file found');
}
};
// Start services
const startServices = () => {
console.log('\n🔧 Starting services...\n');
// Start API Gateway
console.log('📡 Starting API Gateway on port 3000...');
const gateway = spawn('npm', ['run', 'dev'], {
stdio: 'pipe',
shell: true
});
gateway.stdout.on('data', (data) => {
console.log(`[Gateway] ${data.toString().trim()}`);
});
gateway.stderr.on('data', (data) => {
console.log(`[Gateway Error] ${data.toString().trim()}`);
});
// Start Admin Dashboard
console.log('🎛️ Starting Admin Dashboard on port 5173...');
const dashboard = spawn('npm', ['run', 'dev'], {
cwd: path.join(__dirname, 'admin-dashboard'),
stdio: 'pipe',
shell: true
});
dashboard.stdout.on('data', (data) => {
console.log(`[Dashboard] ${data.toString().trim()}`);
});
dashboard.stderr.on('data', (data) => {
console.log(`[Dashboard Error] ${data.toString().trim()}`);
});
// Handle process termination
process.on('SIGINT', () => {
console.log('\n🛑 Shutting down services...');
gateway.kill();
dashboard.kill();
process.exit(0);
});
// Show access URLs after a delay
setTimeout(() => {
console.log('\n🌐 Services are starting up...');
console.log('┌─────────────────────────────────────────────────┐');
console.log('│ Zuplo Platform │');
console.log('├─────────────────────────────────────────────────┤');
console.log('│ 🏠 Landing Page: http://localhost:5173 │');
console.log('│ 📡 API Gateway: http://localhost:3000 │');
console.log('│ 📚 Developer Docs: http://localhost:3000/docs │');
console.log('│ 🔍 Health Check: http://localhost:3000/health│');
console.log('└─────────────────────────────────────────────────┘');
console.log('\n💡 Press Ctrl+C to stop all services');
}, 3000);
};
// Main execution
const main = () => {
try {
checkDependencies();
checkEnvironment();
startServices();
} catch (error) {
console.error('❌ Error starting Zuplo platform:', error.message);
process.exit(1);
}
};
main();