Skip to content

Commit

Permalink
feat: Log output and error for the executed scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamd3vil committed Apr 7, 2022
1 parent c251684 commit 9799a56
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ func handleExecuteScript(scripts string) fastglue.FastRequestHandler {
log.Printf("executing: %s %s", path.Join(scripts, script), strings.Join(args, " "))
output, err := exec.Command(path.Join(scripts, script), args...).CombinedOutput()
if err != nil {
log.Printf("error executing, err: %s, output: %s", err.Error(), output)
r.RequestCtx.WriteString(err.Error())
r.RequestCtx.SetStatusCode(fasthttp.StatusInternalServerError)
return nil
}
log.Println(string(output))
log.Printf("finshed executing: %s %s", path.Join(scripts, script), strings.Join(args, " "))

fmt.Fprint(r.RequestCtx, string(output))
return nil
Expand Down

0 comments on commit 9799a56

Please sign in to comment.