using random free port for electron app #91 #86

This commit is contained in:
Jan Prochazka
2021-04-23 20:49:52 +02:00
parent 65aa6067e1
commit 8caf5d622e
3 changed files with 10 additions and 10 deletions

View File

@@ -31,8 +31,8 @@
"express": "^4.17.1",
"express-basic-auth": "^1.2.0",
"express-fileupload": "^1.2.0",
"find-free-port": "^2.0.0",
"fs-extra": "^9.1.0",
"get-port": "^5.1.1",
"http": "^0.0.0",
"json-stable-stringify": "^1.0.1",
"line-reader": "^0.4.0",
@@ -68,4 +68,4 @@
"optionalDependencies": {
"msnodesqlv8": "^2.0.10"
}
}
}

View File

@@ -6,7 +6,7 @@ const http = require('http');
const cors = require('cors');
const io = require('socket.io');
const fs = require('fs');
const findFreePort = require('find-free-port');
const getPort = require('get-port');
const childProcessChecker = require('./utility/childProcessChecker');
const path = require('path');
const crypto = require('crypto');
@@ -107,7 +107,7 @@ function start() {
authorization = crypto.randomBytes(32).toString('hex');
findFreePort(53911, function (err, port) {
getPort().then(port => {
server.listen(port, () => {
console.log(`DbGate API listening on port ${port}`);
process.send({ msgtype: 'listening', port, authorization });
@@ -115,7 +115,7 @@ function start() {
});
} else if (platformInfo.isNpmDist) {
app.use(express.static(path.join(__dirname, '../../dbgate-web/public')));
findFreePort(5000, function (err, port) {
getPort({ port: 5000 }).then(port => {
server.listen(port, () => {
console.log(`DbGate API listening on port ${port}`);
});