-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (23 loc) · 854 Bytes
/
index.js
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
/**
* @fileoverview Main File (Both frontend and backend)
* @description Main file for both frontend and backend servers.
*/
// Log starting message
console.log('Starting application...');
const { spawn } = require('child_process');
const path = require('path');
/**
* @function startServer - Start a server process.
* @param {string} scriptPath - The path to the server script.
* @param {string} cwd - The current working directory for the server.
*/
function startServer(scriptPath, cwd) {
const server = spawn('node', [scriptPath], { stdio: 'inherit', cwd });
server.on('close', (code) => {
console.log(`${scriptPath} process exited with code ${code}`);
});
}
// Start backend server
startServer('server.js', path.join(__dirname, 'backend'));
// Start frontend server
startServer('server.js', path.join(__dirname, 'frontend'));