aionix 1.0.4 ā 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/index.js +32 -3
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const chalk = require('chalk');
|
|
5
|
-
const
|
|
5
|
+
const net = require('net');
|
|
6
6
|
|
|
7
7
|
console.log(chalk.cyan.bold(`
|
|
8
8
|
+==============================+
|
|
@@ -11,6 +11,35 @@ console.log(chalk.cyan.bold(`
|
|
|
11
11
|
+==============================+
|
|
12
12
|
`));
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// Check which ports are in use
|
|
15
|
+
async function checkPort(port) {
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const server = net.createServer();
|
|
18
|
+
server.listen(port, () => {
|
|
19
|
+
server.close(() => resolve(false)); // free
|
|
20
|
+
});
|
|
21
|
+
server.on('error', () => resolve(true)); // in use
|
|
22
|
+
});
|
|
23
|
+
}
|
|
15
24
|
|
|
16
|
-
|
|
25
|
+
async function showPortStatus() {
|
|
26
|
+
const ports = [3000, 3001, 3002, 3003, 3004];
|
|
27
|
+
console.log(chalk.yellow('\nš” Port Status:'));
|
|
28
|
+
for (const port of ports) {
|
|
29
|
+
const inUse = await checkPort(port);
|
|
30
|
+
if (inUse) {
|
|
31
|
+
console.log(chalk.red(` ā ${port} ā IN USE`));
|
|
32
|
+
} else {
|
|
33
|
+
console.log(chalk.green(` ā ${port} ā free`));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.log('');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function main() {
|
|
40
|
+
await showPortStatus();
|
|
41
|
+
console.log(chalk.green('Starting server...'));
|
|
42
|
+
require('../server/app');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main();
|