new paths for getting waveterm running with monorepo

This commit is contained in:
sawka 2023-10-16 14:02:22 -07:00
parent 688584a1d4
commit 266fc498c7
9 changed files with 75 additions and 64 deletions

View File

@ -63,7 +63,7 @@ module.exports = {
osxSign: {
"hardened-runtime": true,
binaries: [
"Contents/Resources/app/bin/prompt-local-server",
"Contents/Resources/app/bin/wavesrv",
"Contents/Resources/app/bin/mshell/mshell-v0.2-linux.amd64",
"Contents/Resources/app/bin/mshell/mshell-v0.2-linux.arm64",
"Contents/Resources/app/bin/mshell/mshell-v0.2-darwin.amd64",

View File

@ -85,9 +85,9 @@ GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')"
(cd ../apishell; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/bin/mshell/mshell-v0.3-darwin.arm64 main-mshell.go)
(cd ../apishell; GOOS=linux GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/bin/mshell/mshell-v0.3-linux.amd64 main-mshell.go)
(cd ../apishell; GOOS=linux GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/bin/mshell/mshell-v0.3-linux.arm64 main-mshell.go)
(cd ../prompt-server; GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/build/prompt-local-server.amd64 ./cmd)
(cd ../prompt-server; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../prompt-client/build/prompt-local-server.arm64 ./cmd)
lipo -create -output bin/prompt-local-server build/prompt-local-server.amd64 build/prompt-local-server.arm64
(cd wavesrv; GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../build/wavesrv.amd64 ./cmd)
(cd wavesrv; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../build/wavesrv.arm64 ./cmd)
lipo -create -output bin/wavesrv build/wavesrv.amd64 build/wavesrv.arm64
node_modules/.bin/electron-forge make
```
@ -152,7 +152,7 @@ aws --profile prompt-s3 s3 sync webshare/dist s3://prompt-share-static/dist --ca
```bash
# @scripthaus command build-wavesrv
cd wavesrv
go build -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M')" -o bin/local-server ./cmd
go build -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M')" -o bin/wavesrv ./cmd
```
```bash

View File

@ -75,7 +75,7 @@ class App extends React.Component<{}, {}> {
let lineSettingsModal = GlobalModel.lineSettingsModal.get();
let clientSettingsModal = GlobalModel.clientSettingsModal.get();
let remotesModal = GlobalModel.remotesModalModel.isOpen();
let disconnected = !GlobalModel.ws.open.get() || !GlobalModel.localServerRunning.get();
let disconnected = !GlobalModel.ws.open.get() || !GlobalModel.waveSrvRunning.get();
let hasClientStop = GlobalModel.getHasClientStop();
let dcWait = this.dcWait.get();
if (disconnected || hasClientStop) {

View File

@ -6,7 +6,7 @@ import { If, For } from "tsx-control-statements/components";
import cn from "classnames";
import dayjs from "dayjs";
import localizedFormat from "dayjs/plugin/localizedFormat";
import { GlobalModel } from "../../../model/model";
import { GlobalModel, GlobalCommandRunner } from "../../../model/model";
import { Markdown } from "../common";
import * as util from "../../../util/util";
@ -24,7 +24,7 @@ class DisconnectedModal extends React.Component<{}, {}> {
@boundMethod
restartServer() {
GlobalModel.restartLocalServer();
GlobalModel.restartWaveSrv();
}
@boundMethod

View File

@ -21,6 +21,17 @@ function pageSize(div: any): number {
return size;
}
function scrollDiv(div: any, amt: number) {
if (div == null) {
return;
}
let newScrollTop = div.scrollTop + amt;
if (newScrollTop < 0) {
newScrollTop = 0;
}
div.scrollTo({ top: newScrollTop, behavior: "smooth" });
}
@mobxReact.observer
class TextAreaInput extends React.Component<{ onHeightChange: () => void }, {}> {
lastTab: boolean = false;

View File

@ -68,8 +68,8 @@ if (isDev) {
}
let app = electron.app;
app.setName(isDev ? "Prompt (Dev)" : "Prompt");
let localServerProc = null;
let localServerShouldRestart = false;
let waveSrvProc = null;
let waveSrvShouldRestart = false;
electron.dialog.showErrorBox = (title, content) => {
oldConsoleLog("ERROR", title, content);
@ -101,21 +101,21 @@ function getBaseHostPort() {
return ProdServerEndpoint;
}
function getLocalServerPath() {
function getWaveSrvPath() {
if (isDev) {
return path.join(getAppBasePath(), "local-server-bin", "local-server");
return path.join(getAppBasePath(), "wavesrv", "bin", "wavesrv");
}
return path.join(getAppBasePath(), "bin", "prompt-local-server");
return path.join(getAppBasePath(), "bin", "wavesrv");
}
function getLocalServerCmd() {
let localServerPath = getLocalServerPath();
function getWaveSrvCmd() {
let waveSrvPath = getWaveSrvPath();
let scHome = getPromptHomeDir();
let logFile = path.join(scHome, "local-server.log");
return `${localServerPath} >> "${logFile}" 2>&1`;
let logFile = path.join(scHome, "wavesrv.log");
return `${waveSrvPath} >> "${logFile}" 2>&1`;
}
function getLocalServerCwd() {
function getWaveSrvCwd() {
let scHome = getPromptHomeDir();
return scHome;
}
@ -406,18 +406,18 @@ electron.ipcMain.on("get-authkey", (event) => {
return;
});
electron.ipcMain.on("local-server-status", (event) => {
event.returnValue = localServerProc != null;
electron.ipcMain.on("wavesrv-status", (event) => {
event.returnValue = waveSrvProc != null;
return;
});
electron.ipcMain.on("restart-server", (event) => {
if (localServerProc != null) {
localServerProc.kill();
localServerShouldRestart = true;
if (waveSrvProc != null) {
waveSrvProc.kill();
waveSrvShouldRestart = true;
return;
} else {
runLocalServer();
runWaveSrv();
}
event.returnValue = true;
return;
@ -467,25 +467,25 @@ function getClientData(willRetry: boolean, retryNum: number) {
})
.catch((err) => {
if (willRetry) {
console.log("error getting client-data from local-server, will retry", "(" + retryNum + ")");
console.log("error getting client-data from wavesrv, will retry", "(" + retryNum + ")");
return null;
}
console.log("error getting client-data from local-server, failed: ", err);
console.log("error getting client-data from wavesrv, failed: ", err);
return null;
});
}
function sendLSSC() {
function sendWSSC() {
if (MainWindow != null) {
if (localServerProc == null) {
MainWindow.webContents.send("local-server-status-change", false);
if (waveSrvProc == null) {
MainWindow.webContents.send("wavesrv-status-change", false);
return;
}
MainWindow.webContents.send("local-server-status-change", true, localServerProc.pid);
MainWindow.webContents.send("wavesrv-status-change", true, waveSrvProc.pid);
}
}
function runLocalServer() {
function runWaveSrv() {
let pResolve = null;
let pReject = null;
let rtnPromise = new Promise((argResolve, argReject) => {
@ -497,31 +497,31 @@ function runLocalServer() {
if (isDev) {
envCopy[PromptDevVarName] = "1";
}
console.log("trying to run local server", getLocalServerPath());
let proc = child_process.spawn("/bin/bash", ["-c", getLocalServerCmd()], {
cwd: getLocalServerCwd(),
console.log("trying to run local server", getWaveSrvPath());
let proc = child_process.spawn("/bin/bash", ["-c", getWaveSrvCmd()], {
cwd: getWaveSrvCwd(),
env: envCopy,
});
proc.on("exit", (e) => {
console.log("local-server exit", e);
localServerProc = null;
sendLSSC();
pReject(new Error(sprintf("failed to start local server (%s)", getLocalServerPath())));
if (localServerShouldRestart) {
localServerShouldRestart = false;
this.runLocalServer();
console.log("wavesrv exit", e);
waveSrvProc = null;
sendWSSC();
pReject(new Error(sprintf("failed to start local server (%s)", getWaveSrvPath())));
if (waveSrvShouldRestart) {
waveSrvShouldRestart = false;
this.runWaveSrv();
}
});
proc.on("spawn", (e) => {
console.log("spawnned local-server");
localServerProc = proc;
console.log("spawnned wavesrv");
waveSrvProc = proc;
pResolve(true);
setTimeout(() => {
sendLSSC();
sendWSSC();
}, 100);
});
proc.on("error", (e) => {
console.log("error running local-server", e);
console.log("error running wavesrv", e);
});
proc.stdout.on("data", (output) => {
return;
@ -561,7 +561,7 @@ async function createMainWindowWrap() {
try {
clientData = await getClientDataPoll(1);
} catch (e) {
console.log("error getting local-server clientdata", e.toString());
console.log("error getting wavesrv clientdata", e.toString());
}
MainWindow = createMainWindow(clientData);
if (clientData && clientData.winsize.fullscreen) {
@ -604,7 +604,7 @@ function runActiveTimer() {
}
GlobalAuthKey = readAuthKey();
try {
await runLocalServer();
await runWaveSrv();
} catch (e) {
console.log(e.toString());
}

View File

@ -4,8 +4,8 @@ contextBridge.exposeInMainWorld("api", {
getId: () => ipcRenderer.sendSync("get-id"),
getIsDev: () => ipcRenderer.sendSync("get-isdev"),
getAuthKey: () => ipcRenderer.sendSync("get-authkey"),
getLocalServerStatus: () => ipcRenderer.sendSync("local-server-status"),
restartLocalServer: () => ipcRenderer.sendSync("restart-server"),
getWaveSrvStatus: () => ipcRenderer.sendSync("wavesrv-status"),
restartWaveSrv: () => ipcRenderer.sendSync("restart-server"),
reloadWindow: () => ipcRenderer.sendSync("reload-window"),
onTCmd: (callback) => ipcRenderer.on("t-cmd", callback),
onICmd: (callback) => ipcRenderer.on("i-cmd", callback),
@ -20,5 +20,5 @@ contextBridge.exposeInMainWorld("api", {
onDigitCmd: (callback) => ipcRenderer.on("digit-cmd", callback),
contextScreen: (screenOpts, position) => ipcRenderer.send("context-screen", screenOpts, position),
contextEditMenu: (position, opts) => ipcRenderer.send("context-editmenu", position, opts),
onLocalServerStatusChange: (callback) => ipcRenderer.on("local-server-status-change", callback),
onWaveSrvStatusChange: (callback) => ipcRenderer.on("wavesrv-status-change", callback),
});

View File

@ -166,8 +166,8 @@ type ElectronApi = {
getId: () => string;
getIsDev: () => boolean;
getAuthKey: () => string;
getLocalServerStatus: () => boolean;
restartLocalServer: () => boolean;
getWaveSrvStatus: () => boolean;
restartWaveSrv: () => boolean;
reloadWindow: () => void;
onTCmd: (callback: (mods: KeyModsType) => void) => void;
onICmd: (callback: (mods: KeyModsType) => void) => void;
@ -181,7 +181,7 @@ type ElectronApi = {
onDigitCmd: (callback: (event: any, arg: { digit: number }, mods: KeyModsType) => void) => void;
contextScreen: (screenOpts: { screenId: string }, position: { x: number; y: number }) => void;
contextEditMenu: (position: { x: number; y: number }, opts: ContextMenuOpts) => void;
onLocalServerStatusChange: (callback: (status: boolean, pid: number) => void) => void;
onWaveSrvStatusChange: (callback: (status: boolean, pid: number) => void) => void;
};
function getApi(): ElectronApi {
@ -2637,7 +2637,7 @@ class Model {
termUsedRowsCache: Record<string, number> = {}; // key = "screenid/lineid"
debugCmds: number = 0;
debugScreen: OV<boolean> = mobx.observable.box(false);
localServerRunning: OV<boolean>;
waveSrvRunning: OV<boolean>;
authKey: string;
isDev: boolean;
activeMainView: OV<"session" | "history" | "bookmarks" | "webshare"> = mobx.observable.box("session", {
@ -2687,9 +2687,9 @@ class Model {
this.bookmarksModel = new BookmarksModel();
this.historyViewModel = new HistoryViewModel();
this.remotesModalModel = new RemotesModalModel();
let isLocalServerRunning = getApi().getLocalServerStatus();
this.localServerRunning = mobx.observable.box(isLocalServerRunning, {
name: "model-local-server-running",
let isWaveSrvRunning = getApi().getWaveSrvStatus();
this.waveSrvRunning = mobx.observable.box(isWaveSrvRunning, {
name: "model-wavesrv-running",
});
this.termFontSize = mobx.computed(() => {
let cdata = this.clientData.get();
@ -2715,7 +2715,7 @@ class Model {
getApi().onMetaPageDown(this.onMetaPageDown.bind(this));
getApi().onBracketCmd(this.onBracketCmd.bind(this));
getApi().onDigitCmd(this.onDigitCmd.bind(this));
getApi().onLocalServerStatusChange(this.onLocalServerStatusChange.bind(this));
getApi().onWaveSrvStatusChange(this.onWaveSrvStatusChange.bind(this));
document.addEventListener("keydown", this.docKeyDownHandler.bind(this));
document.addEventListener("selectionchange", this.docSelectionChangeHandler.bind(this));
setTimeout(() => this.getClientDataLoop(1), 10);
@ -2923,8 +2923,8 @@ class Model {
return didSomething;
}
restartLocalServer(): void {
getApi().restartLocalServer();
restartWaveSrv(): void {
getApi().restartWaveSrv();
}
getLocalRemote(): RemoteType {
@ -2944,9 +2944,9 @@ class Model {
return screen.getCurRemoteInstance();
}
onLocalServerStatusChange(status: boolean): void {
onWaveSrvStatusChange(status: boolean): void {
mobx.action(() => {
this.localServerRunning.set(status);
this.waveSrvRunning.set(status);
})();
}

View File

@ -18,8 +18,8 @@ import (
"sync"
"time"
"github.com/wavetermdev/waveterm/waveshell/pkg/base"
"github.com/google/uuid"
"github.com/wavetermdev/waveterm/waveshell/pkg/base"
"golang.org/x/mod/semver"
"golang.org/x/sys/unix"
)
@ -73,7 +73,7 @@ func MShellBinaryDir() string {
appPath = "."
}
if IsDevMode() {
return path.Join(appPath, "dev-bin")
return path.Join(appPath, "waveshell", "bin")
}
return path.Join(appPath, "bin", "mshell")
}