forked from Mikasuru/KukuriClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStart.js
More file actions
35 lines (30 loc) · 1000 Bytes
/
Copy pathStart.js
File metadata and controls
35 lines (30 loc) · 1000 Bytes
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
const Logger = require('./Module/Logger');
const { execSync, spawn } = require('child_process');
const path = require('path');
function checkRuntime() {
try {
execSync('bun -v', { stdio: 'pipe' });
return 'bun';
} catch {
try {
execSync('npm -v', { stdio: 'pipe' });
return 'npm';
} catch {
Logger.expection('Neither Bun nor NPM found in system');
process.exit(1); // Exit process if no runtime is found
}
}
}
const runtime = checkRuntime();
const command = runtime === 'bun' ? 'bun' : 'node';
const child = spawn(command, [path.join('Server', 'app.js')], {
stdio: 'inherit',
});
child.on('close', (code) => {
if (code === 0) {
Logger.info('Server process exited successfully.');
} else {
Logger.expection(`Server process exited with code ${code}`);
}
});
Logger.load('Server started successfully, waiting for termination...');