diff --git a/cmd/server/main-server.go b/cmd/server/main-server.go index b6e5239cd..5b9944693 100644 --- a/cmd/server/main-server.go +++ b/cmd/server/main-server.go @@ -62,6 +62,9 @@ func stdinReadWatch() { } func main() { + log.SetFlags(log.LstdFlags | log.Lmicroseconds) + log.SetPrefix("[wavesrv] ") + err := service.ValidateServiceMap() if err != nil { log.Printf("error validating service map: %v\n", err) diff --git a/emain/emain.ts b/emain/emain.ts index e552efa10..a8db3c715 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -4,6 +4,7 @@ import * as electron from "electron"; import * as child_process from "node:child_process"; import * as path from "path"; +import * as readline from "readline"; import { debounce } from "throttle-debounce"; import * as services from "../frontend/app/store/services"; @@ -59,13 +60,6 @@ function getWaveSrvPath(): string { return path.join(getGoAppBasePath(), "bin", "wavesrv"); } -function getWaveSrvCmd(): string { - const waveSrvPath = getWaveSrvPath(); - const waveHome = getWaveHomeDir(); - const logFile = path.join(waveHome, "wavesrv.log"); - return `"${waveSrvPath}" >> "${logFile}" 2>&1`; -} - function getWaveSrvCwd(): string { return getWaveHomeDir(); } @@ -83,9 +77,9 @@ function runWaveSrv(): Promise { envCopy[WaveDevVarName] = "1"; } envCopy[WaveSrvReadySignalPidVarName] = process.pid.toString(); - const waveSrvCmd = getWaveSrvCmd(); + const waveSrvCmd = getWaveSrvPath(); console.log("trying to run local server", waveSrvCmd); - const proc = child_process.execFile("bash", ["-c", waveSrvCmd], { + const proc = child_process.spawn(getWaveSrvPath(), { cwd: getWaveSrvCwd(), env: envCopy, }); @@ -102,11 +96,19 @@ function runWaveSrv(): Promise { console.log("error running wavesrv", e); pReject(e); }); - proc.stdout.on("data", (_) => { - return; + const rlStdout = readline.createInterface({ + input: proc.stdout, + terminal: false, }); - proc.stderr.on("data", (_) => { - return; + rlStdout.on("line", (line) => { + console.log(line); + }); + const rlStderr = readline.createInterface({ + input: proc.stderr, + terminal: false, + }); + rlStderr.on("line", (line) => { + console.log(line); }); return rtnPromise; } diff --git a/pkg/blockcontroller/blockcontroller.go b/pkg/blockcontroller/blockcontroller.go index ad585507b..4d9827913 100644 --- a/pkg/blockcontroller/blockcontroller.go +++ b/pkg/blockcontroller/blockcontroller.go @@ -235,12 +235,12 @@ func (bc *BlockController) Run(bdata *wstore.Block) { for genCmd := range bc.InputCh { switch cmd := genCmd.(type) { case *BlockInputCommand: - fmt.Printf("INPUT: %s | %q\n", bc.BlockId, cmd.InputData64) + log.Printf("INPUT: %s | %q\n", bc.BlockId, cmd.InputData64) if bc.ShellInputCh != nil { bc.ShellInputCh <- cmd } default: - fmt.Printf("unknown command type %T\n", cmd) + log.Printf("unknown command type %T\n", cmd) } } } diff --git a/pkg/util/utilfn/utilfn.go b/pkg/util/utilfn/utilfn.go index 69bd63ba3..850483d9a 100644 --- a/pkg/util/utilfn/utilfn.go +++ b/pkg/util/utilfn/utilfn.go @@ -725,14 +725,3 @@ func IndentString(indent string, str string) string { } return rtn.String() } - -func PrintIndentedStr(indent string, str string) { - splitArr := strings.Split(str, "\n") - for _, line := range splitArr { - if line == "" { - fmt.Printf("\n") - continue - } - fmt.Printf("%s%s\n", indent, line) - } -}