Skip to content

Commit

Permalink
Merge pull request #3023 from input-output-hk/chore/manus-webdriver-m…
Browse files Browse the repository at this point in the history
…ocha-setup--better-darwin-launcher

[DDW-1122] Fix `darwin-launcher.go` to replace its process image with `cardano-launcher` (binary), and not swallow `stdout`
  • Loading branch information
danielmain committed Jul 28, 2022
2 parents d8a96ec + 24991f6 commit af8e56a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@

### Chores

- Fix `darwin-launcher.go` to replace its process image with `cardano-launcher` (binary), and not swallow `stdout` ([PR 3023](https://github.com/input-output-hk/daedalus/pull/3023))
- Updated cardano-node to 1.35.1 ([PR 3012](https://github.com/input-output-hk/daedalus/pull/3012))

### Features
Expand Down
24 changes: 18 additions & 6 deletions nix/darwin-launcher.go
Expand Up @@ -5,9 +5,12 @@ import (
"os"
"os/exec"
"path/filepath"
"syscall"
)

func main() {
fmt.Fprintf(os.Stderr, "darwin-launcher: PID = %d\n", os.Getpid())

ex, err := os.Executable()
if err != nil {
panic(err)
Expand All @@ -17,14 +20,23 @@ func main() {

os.Setenv("PATH", fmt.Sprintf("%s:%s", installDir, os.Getenv("PATH")))

launcherConfig := filepath.Join(installDir, "../Resources/launcher-config.yaml")
helper := filepath.Join(installDir, "../Resources/helper")

launcherConfigPath := filepath.Join(installDir, "../Resources/launcher-config.yaml")
helperPath := filepath.Join(installDir, "../Resources/helper")

if err = exec.Command(helper).Run(); err != nil {
helperCmd := exec.Command(helperPath)
helperCmd.Stdout = os.Stdout
helperCmd.Stderr = os.Stderr
if err := helperCmd.Run(); err != nil {
panic(err)
}
if err = exec.Command("cardano-launcher", "--config", launcherConfig).Run(); err != nil {
panic(err)

// Replace the current process (otherwise WDIO complains in end-to-end tests):
img := filepath.Join(installDir, "cardano-launcher")
argv := []string{"cardano-launcher", "--config", launcherConfigPath}
env := os.Environ()
if err := syscall.Exec(img, argv, env); err != nil {
fmt.Println(err)
}

fmt.Fprintf(os.Stderr, "this won’t happen\n")
}

0 comments on commit af8e56a

Please sign in to comment.