Skip to content

Commit ef386ad

Browse files
author
Shlomi Noach
committed
hook output and err are written to gh-ost's stderr
1 parent 6760200 commit ef386ad

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

go/logic/hooks.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ func (this *HooksExecutor) applyEnvironmentVairables(extraVariables ...string) [
6565
}
6666

6767
// executeHook executes a command, and sets relevant environment variables
68+
// combined output & error are printed to gh-ost's standard error.
6869
func (this *HooksExecutor) executeHook(hook string, extraVariables ...string) error {
6970
cmd := exec.Command(hook)
7071
cmd.Env = this.applyEnvironmentVairables(extraVariables...)
7172

72-
if err := cmd.Run(); err != nil {
73-
return log.Errore(err)
74-
}
75-
return nil
73+
combinedOutput, err := cmd.CombinedOutput()
74+
fmt.Fprintln(os.Stderr, string(combinedOutput))
75+
return log.Errore(err)
7676
}
7777

7878
func (this *HooksExecutor) detectHooks(baseName string) (hooks []string, err error) {

resources/hooks-sample/gh-ost-on-success-hook-2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# Sample hook file for gh-ost-on-success
44

5-
echo "$(date) gh-ost-on-success $GH_OST_DATABASE_NAME.$GH_OST_TABLE_NAME" >> /tmp/gh-ost.log
5+
echo "$(date) gh-ost-on-success $GH_OST_DATABASE_NAME.$GH_OST_TABLE_NAME -- this message should show on the gh-ost log"

0 commit comments

Comments
 (0)