Added clientonly script

Added clientonly script to have server and client run at different locations
This commit is contained in:
Unknown 2017-06-25 12:18:59 +02:00 committed by unknown
parent 8893df118e
commit 66f93ee541
8 changed files with 118 additions and 6 deletions

View file

@ -6,7 +6,7 @@ const electron = require("electron");
const core = require(__dirname + "/app.js");
// Config
var config = {};
var config = process.env.config ? JSON.parse(process.env.config) : {};
// Module to control application life.
const app = electron.app;
// Module to create native browser window.
@ -47,7 +47,7 @@ function createWindow() {
// and load the index.html of the app.
//mainWindow.loadURL('file://' + __dirname + '../../index.html');
mainWindow.loadURL("http://localhost:" + config.port);
mainWindow.loadURL(`http://${config.address}:${config.port}`);
// Open the DevTools if run with "npm start dev"
if (process.argv.includes("dev")) {
@ -96,8 +96,10 @@ app.on("activate", function() {
}
});
// Start the core application.
// Start the core application if server is run on localhost
// This starts all node helpers and starts the webserver.
core.start(function(c) {
config = c;
});
if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].indexOf(config.address) > -1) {
core.start(function (c) {
config = c;
});
}