From 4641271bfaaa17b5248c89a0248f8a951670cb97 Mon Sep 17 00:00:00 2001 From: sawka Date: Thu, 8 Aug 2024 13:39:17 -0700 Subject: [PATCH] show the buildtimes in the about page --- cmd/server/main-server.go | 2 +- emain/emain.ts | 34 ++++++++++++++++++---------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/cmd/server/main-server.go b/cmd/server/main-server.go index 0759eeef5..ba5604036 100644 --- a/cmd/server/main-server.go +++ b/cmd/server/main-server.go @@ -158,7 +158,7 @@ func main() { _, err := strconv.Atoi(pidStr) if err == nil { // use fmt instead of log here to make sure it goes directly to stderr - fmt.Fprintf(os.Stderr, "WAVESRV-ESTART ws:%s web:%s\n", wsListener.Addr(), webListener.Addr()) + fmt.Fprintf(os.Stderr, "WAVESRV-ESTART ws:%s web:%s version:%s buildtime:%s\n", wsListener.Addr(), webListener.Addr(), WaveVersion, BuildTime) } } }() diff --git a/emain/emain.ts b/emain/emain.ts index 637e3756e..901df24cc 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -20,6 +20,8 @@ import { fireAndForget } from "../frontend/util/util"; import { configureAutoUpdater, updater } from "./updater"; const electronApp = electron.app; +let WaveVersion = "unknown"; // set by WAVESRV-ESTART +let WaveBuildTime = 0; // set by WAVESRV-ESTART const WaveAppPathVarName = "WAVETERM_APP_PATH"; const WaveSrvReadySignalPidVarName = "WAVETERM_READY_SIGNAL_PID"; @@ -113,15 +115,14 @@ function getGoAppBasePath(): string { const wavesrvBinName = `wavesrv.${unameArch}`; function getWaveSrvPath(): string { + if (process.platform === "win32") { + const winBinName = `${wavesrvBinName}.exe`; + const appPath = path.join(getGoAppBasePath(), "bin", winBinName); + return `& "${appPath}"`; + } return path.join(getGoAppBasePath(), "bin", wavesrvBinName); } -function getWaveSrvPathWin(): string { - const winBinName = `${wavesrvBinName}.exe`; - const appPath = path.join(getGoAppBasePath(), "bin", winBinName); - return `& "${appPath}"`; -} - function getWaveSrvCwd(): string { return getWaveHomeDir(); } @@ -141,12 +142,7 @@ function runWaveSrv(): Promise { const envCopy = { ...process.env }; envCopy[WaveAppPathVarName] = getGoAppBasePath(); envCopy[WaveSrvReadySignalPidVarName] = process.pid.toString(); - let waveSrvCmd: string; - if (process.platform === "win32") { - waveSrvCmd = getWaveSrvPathWin(); - } else { - waveSrvCmd = getWaveSrvPath(); - } + const waveSrvCmd = getWaveSrvPath(); console.log("trying to run local server", waveSrvCmd); const proc = child_process.spawn(getWaveSrvPath(), { cwd: getWaveSrvCwd(), @@ -181,14 +177,20 @@ function runWaveSrv(): Promise { }); rlStderr.on("line", (line) => { if (line.includes("WAVESRV-ESTART")) { - const addrs = /ws:([a-z0-9.:]+) web:([a-z0-9.:]+)/gm.exec(line); - if (addrs == null) { + const startParams = /ws:([a-z0-9.:]+) web:([a-z0-9.:]+) version:([a-z0-9.]+) buildtime:(\d+)/gm.exec(line); + if (startParams == null) { console.log("error parsing WAVESRV-ESTART line", line); electronApp.quit(); return; } - process.env[WSServerEndpointVarName] = addrs[1]; - process.env[WebServerEndpointVarName] = addrs[2]; + process.env[WSServerEndpointVarName] = startParams[1]; + process.env[WebServerEndpointVarName] = startParams[2]; + WaveVersion = startParams[3]; + WaveBuildTime = parseInt(startParams[4]); + electron.app.setAboutPanelOptions({ + applicationVersion: "v" + WaveVersion, + version: (isDev ? "dev-" : "") + String(WaveBuildTime), + }); waveSrvReadyResolve(true); return; }