This repository was archived by the owner on Sep 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathapp.js
More file actions
68 lines (61 loc) · 1.95 KB
/
app.js
File metadata and controls
68 lines (61 loc) · 1.95 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
/**
* Main app script command which runs all nodejs servers at once
*/
const { exec } = require('child_process'); // native in nodeJs
const { frontendConfig, apiConfig, authConfig, adminConfig, imageConfig } = require('./config.js');
const { objectToAline } = require('./utils.js');
// commands list
const commands = [
// {
// name: 'Frontend',
// command: `cd ./openstad-frontend && ${objectToAline(frontendConfig)} npm run dev`
// },
// {
// name: 'Api',
// command: `cd ./openstad-api && ${objectToAline(apiConfig)} npm run dev`
// },
// {
// name: 'Admin',
// command: `cd ./openstad-management-panel && ${objectToAline(adminConfig)} npm run dev`
// },
// {
// name: 'Image',
// command: `cd ./image-server && ${objectToAline(imageConfig)} node server.js`
// },
{
name: 'Auth',
command: `cd ./openstad-management-panel && ${objectToAline(adminConfig)} npm run dev`
},
];
// run command
function runCommand(command, name, callback) {
child_process.exec(command, function (error, stdout, stderr) {
if (stderr) {
callback(stderr, null);
} else {
callback(null, `Successfully executed ${name} ...`);
}
});
}
async function execWaitForOutput(command, execOptions = {}) {
return new Promise((resolve, reject) => {
console.log('++++', adminConfig);
const childProcess = exec(command, execOptions);
// stream process output to console
childProcess.stderr.on('data', data => console.error(data));
childProcess.stdout.on('data', data => console.log(data));
// handle exit
childProcess.on('exit', () => resolve());
childProcess.on('close', () => resolve());
// handle errors
childProcess.on('error', error => reject(error));
})
}
// main calling function
async function main() {
commands.forEach(async (element) => {
await execWaitForOutput(element.command);
});
}
// call main
main();