From 1ddf398e8ec3a1512d270a722fa0deb9deae085f Mon Sep 17 00:00:00 2001 From: openbuilds-engineer Date: Thu, 27 Apr 2023 20:31:02 +0200 Subject: [PATCH] v1.0.367 --- CHANGELOG.txt | 1 + index.js | 65 +++++++++------------------------------------------ package.json | 2 +- 3 files changed, 13 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c91c0ec..5f13879 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,4 @@ +v1.0.367: Fixed 'indexOf' startup Bug - removed Port Conflict Detection v1.0.366: Improved grblHAL integration (Additional Homing Enable Masks) v1.0.365: Increased Updater snooze to 8hr interval, Improved port-confict handling, Improved Recovery wizard to deal with Laser files v1.0.364: Fixed bug in Surfacing Wizard Freeze bug (Special thanks to Armaliteguy for providing debug info) diff --git a/index.js b/index.js index 82502e3..f1ff136 100644 --- a/index.js +++ b/index.js @@ -1,35 +1,9 @@ process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = '1'; process.on('uncaughtException', function(err) { - showErrorDialog(err, attempts = 2) // make two attempts to show an uncaughtException in a dialog - if (DEBUG) { - debug_log(err) - } else { - console.log(err); - } + console.log(err); }) -function showErrorDialog(err, attempts) { - console.error('Attempting to show an error dialog.') - if (!attempts) return; - try { - let options = { - type: 'error', - buttons: ['OK'], - title: 'Error', - message: `An error occured.`, - detail: `${err.message}\r\r\rIf you feel this shouldn't be happening, please report it at:\r\rhttps://github.com/OpenBuilds/OpenBuilds-CONTROL/issues`, - }; - let window = BrowserWindow.getFocusedWindow() - dialog.showMessageBoxSync(window, options) - } catch (e) { - console.error(`An error occurred trying show an error, ho-boy. ${e}. We'll try again ${attempts} more time(s).`) - setTimeout(() => { - showErrorDialog(err, --attempts) - }, millisecondDelay = 2000); - } -} - // To see console.log output run with `DEBUGCONTROL=true electron .` or set environment variable for DEBUGCONTROL=true // debug_log debug overhead DEBUG = false; @@ -44,20 +18,14 @@ function debug_log() { } } // end Debug Logger +process.on("uncaughtException", (err) => { + debug_log(err) +}); + debug_log("Starting OpenBuilds CONTROL v" + require('./package').version) var config = {}; -config.webPorts = [3000, 3020, 3200, 3220] -config.webPortIdx = 0; -config.nextWebPort = function() { - config.webPort = config.webPorts[config.webPortIdx] - config.webPortIdx++ - if (config.webPortIdx == config.webPorts.length) { - throw new Error(`No ports were available to start the http server.\r\rWe tried ports ${config.webPorts.join(",")}.`); - } - return config.webPort; -} -config.webPort = process.env.WEB_PORT || config.nextWebPort(); +config.webPort = process.env.WEB_PORT || 3000; config.posDecimals = process.env.DRO_DECIMALS || 2; config.grblWaitTime = 0.5; config.firmwareWaitTime = 4; @@ -142,20 +110,9 @@ const httpsserver = https.createServer(httpsOptions, app).listen(3001, function( debug_log('https: listening on:' + ip.address() + ":3001"); }); -const httpserver = http.listen(config.webPort, '0.0.0.0', httpServerSuccess).on('error', httpServerError); - -function httpServerSuccess() { +const httpserver = http.listen(config.webPort, '0.0.0.0', function() { debug_log('http: listening on:' + ip.address() + ":" + config.webPort); - if (jogWindow) { - jogWindow.loadURL(`http://localhost:${config.webPort}/`); - } -} - -function httpServerError(error) { - // If unable to start (port in use) - try next port in array from config.nextWebPort() - console.error(error.message); - httpserver.listen(config.nextWebPort()); -} +}); io.attach(httpserver); io.attach(httpsserver); @@ -277,7 +234,7 @@ if (isElectron()) { // repeat every minute setTimeout(function() { io.sockets.emit('updateready', availversion); - }, 1000 * 60 * 60 * 8) // 8hrs before alerting again if it was snoozed + }, 8 * 60 * 60 * 1000) // 60 mins updateIsDownloading = false; }); } else { @@ -3077,7 +3034,7 @@ if (isElectron()) { jogWindow.setOverlayIcon(nativeImage.createFromPath(iconPath), 'Icon'); var ipaddr = ip.address(); // jogWindow.loadURL(`//` + ipaddr + `:3000/`) - jogWindow.loadURL(`http://localhost:${config.webPort}/`); + jogWindow.loadURL("http://localhost:3000/"); //jogWindow.webContents.openDevTools() jogWindow.on('close', function(event) { @@ -3273,7 +3230,7 @@ function startChrome() { const { spawn } = require('child_process'); - const chrome = spawn('chromium-browser', [`-app=http://127.0.0.1:${config.webPort}`]); + const chrome = spawn('chromium-browser', ['-app=http://127.0.0.1:3000']); chrome.on('close', (code) => { debug_log(`Chromium process exited with code ${code}`); process.exit(0); diff --git a/package.json b/package.json index e3cf621..ab09947 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "OpenBuildsCONTROL", - "version": "1.0.366", + "version": "1.0.367", "license": "AGPL-3.0", "description": "OpenBuildsCONTROL CNC Machine Host Software", "author": "github.com/openbuilds ",