Skip to content

Commit

Permalink
Pipe stdout/stderr of utils.RunCommand to machine logs (#228)
Browse files Browse the repository at this point in the history
* Pipe stdout/stderr of utils.RunCommand to machine logs

This will allow us to immediately see any errors if any commands fail

* use log
  • Loading branch information
benwaffle authored and davissp14 committed Jun 25, 2024
1 parent 17ed339 commit 30978f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/flypg/state/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func clientConfig() (*api.Config, error) {

token, set := u.User.Password()
if !set {
return nil, fmt.Errorf("token not set")
return nil, fmt.Errorf("consul token not set")
}

u.User = nil
Expand Down
3 changes: 3 additions & 0 deletions internal/utils/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"log"
"os"
"os/exec"
"os/user"
Expand All @@ -17,6 +18,8 @@ func RunCommand(cmdStr, usr string) ([]byte, error) {
return nil, err
}

log.Printf("> Running command as %s: %s\n", usr, cmdStr)

cmd := exec.Command("sh", "-c", cmdStr)
cmd.SysProcAttr = &syscall.SysProcAttr{}
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
Expand Down

0 comments on commit 30978f9

Please sign in to comment.