mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-31 00:23:57 +00:00
Run local server while inside packed version, Fixes: #310
This commit is contained in:
parent
3cf7492452
commit
50b12f54d8
@ -17,6 +17,9 @@ files:
|
||||
- local-server.js
|
||||
- package.json
|
||||
|
||||
extraFiles:
|
||||
- dist/exe.gns3server/**
|
||||
|
||||
mac:
|
||||
category: public.app-category.developer-tools
|
||||
# publish: github
|
||||
|
@ -3,34 +3,23 @@ const kill = require('tree-kill');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { ipcMain } = require('electron')
|
||||
const { app } = require('electron')
|
||||
|
||||
const isWin = /^win/.test(process.platform);
|
||||
|
||||
let runningServers = {};
|
||||
|
||||
exports.getLocalServerPath = async () => {
|
||||
const distDirectory = path.join(__dirname, 'dist');
|
||||
if (!fs.existsSync(distDirectory)) {
|
||||
return;
|
||||
}
|
||||
const lookupDirectories = [
|
||||
__dirname,
|
||||
path.dirname(app.getPath('exe'))
|
||||
];
|
||||
|
||||
const files = fs.readdirSync(distDirectory);
|
||||
|
||||
let serverPath = null;
|
||||
|
||||
files.forEach((directory) => {
|
||||
if(directory.startsWith('exe.')) {
|
||||
if (isWin) {
|
||||
serverPath = path.join(__dirname, 'dist', directory, 'gns3server.exe');
|
||||
}
|
||||
else {
|
||||
serverPath = path.join(__dirname, 'dist', directory, 'gns3server');
|
||||
}
|
||||
for(var directory of lookupDirectories) {
|
||||
const serverPath = await findLocalServerPath(directory);
|
||||
if(serverPath !== undefined) {
|
||||
return serverPath;
|
||||
}
|
||||
});
|
||||
|
||||
if(serverPath !== null && fs.existsSync(serverPath)) {
|
||||
return serverPath;
|
||||
}
|
||||
|
||||
return;
|
||||
@ -54,6 +43,35 @@ exports.stopAllLocalServers = async () => {
|
||||
return await stopAll();
|
||||
}
|
||||
|
||||
async function findLocalServerPath(baseDirectory) {
|
||||
const distDirectory = path.join(baseDirectory, 'dist');
|
||||
|
||||
if (!fs.existsSync(distDirectory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(distDirectory);
|
||||
|
||||
let serverPath = null;
|
||||
|
||||
files.forEach((directory) => {
|
||||
if(directory.startsWith('exe.')) {
|
||||
if (isWin) {
|
||||
serverPath = path.join(baseDirectory, 'dist', directory, 'gns3server.exe');
|
||||
}
|
||||
else {
|
||||
serverPath = path.join(baseDirectory, 'dist', directory, 'gns3server');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(serverPath !== null && fs.existsSync(serverPath)) {
|
||||
return serverPath;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function getServerArguments(server, overrides) {
|
||||
let serverArguments = [];
|
||||
if(server.host) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user