Skip to content

Commit

Permalink
episode 891
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Jan 2, 2024
1 parent 3220961 commit 218dc8e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions publisher/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/http"
"os"
"os/exec"
"strings"

Expand Down Expand Up @@ -54,7 +55,8 @@ type ShellExecutor struct {
func (c *ShellExecutor) Run(cmd string, params ...string) {
command := fmt.Sprintf("%s %s", cmd, strings.Join(params, " "))
if err := c.do(command); err != nil {
log.Fatalf("[ERROR] %v", err)
log.Printf("[ERROR] %v", err)
os.Exit(1) // failed cmd stops everything
}
}

Expand All @@ -67,5 +69,5 @@ func (c *ShellExecutor) do(cmd string) error {
ex := exec.Command("sh", "-c", cmd)
ex.Stdout = lgr.ToWriter(lgr.Default(), "INFO")
ex.Stderr = lgr.ToWriter(lgr.Default(), "WARN")
return errors.Wrapf(ex.Run(), "failed to run %q", cmd)
return errors.Wrapf(ex.Run(), "failed to run command: %s", cmd)
}

0 comments on commit 218dc8e

Please sign in to comment.