feat: Banque des Coquillages v1.0 avec Docker et configuration NPM
This commit is contained in:
54
start-all.js
Normal file
54
start-all.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { spawn } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
function runNode(name, colorCode, args, cwd) {
|
||||
const child = spawn(process.execPath, args, {
|
||||
cwd,
|
||||
stdio: 'pipe'
|
||||
});
|
||||
|
||||
child.stdout.on('data', (data) => {
|
||||
const lines = data.toString().split(/\r?\n/).filter(Boolean);
|
||||
for (const line of lines) {
|
||||
console.log(`\x1b[${colorCode}m[${name}]\x1b[0m ${line}`);
|
||||
}
|
||||
});
|
||||
|
||||
child.stderr.on('data', (data) => {
|
||||
const lines = data.toString().split(/\r?\n/).filter(Boolean);
|
||||
for (const line of lines) {
|
||||
console.error(`\x1b[${colorCode}m[${name}]\x1b[0m ${line}`);
|
||||
}
|
||||
});
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
console.log('🐚 Démarrage simultané du Backend (port 4050) et du Frontend (port 5180)...');
|
||||
|
||||
const back = runNode(
|
||||
'BACK ',
|
||||
'36',
|
||||
['--watch', path.join(__dirname, 'back', 'src', 'server.js')],
|
||||
path.join(__dirname, 'back')
|
||||
);
|
||||
|
||||
const front = runNode(
|
||||
'FRONT',
|
||||
'33',
|
||||
[path.join(__dirname, 'node_modules', 'vite', 'bin', 'vite.js')],
|
||||
path.join(__dirname, 'front')
|
||||
);
|
||||
|
||||
function shutdown() {
|
||||
back.kill();
|
||||
front.kill();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGTERM', shutdown);
|
||||
Reference in New Issue
Block a user