-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
47 lines (40 loc) Β· 1.5 KB
/
Copy pathstart.js
File metadata and controls
47 lines (40 loc) Β· 1.5 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
import { spawn } from 'child_process';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('=======================================================');
console.log('π― Olive AI LLM TELEMETRY SYSTEM LAUNCHER');
console.log('=======================================================');
const nodeModulesPath = path.join(__dirname, 'node_modules');
// 1. If node_modules is missing, run npm install automatically
if (!fs.existsSync(nodeModulesPath)) {
console.log('π¦ node_modules folder not found. Automatically running "npm install"...');
const npmInstall = spawn('npm', ['install'], {
shell: true,
stdio: 'inherit',
cwd: __dirname
});
npmInstall.on('close', (code) => {
if (code === 0) {
console.log('β
Dependencies successfully installed.');
bootExpressServer();
} else {
console.error(`β Dependency installation failed (exit code ${code}).`);
console.error('Please run "npm install" manually before running start.js.');
}
});
} else {
// 2. If node_modules exists, boot the Express server instantly
bootExpressServer();
}
/**
* Dynamically imports and boots the main Express application
*/
function bootExpressServer() {
console.log('π Initializing databases and starting telemetry server...');
import('./server/index.js').catch(err => {
console.error('β Failed to launch backend server:', err.message);
});
}