hook output and err are written to gh-ost's stderr

This commit is contained in:
Shlomi Noach 2016-08-25 16:08:49 +02:00
parent 676020000a
commit ef386add5c
2 changed files with 5 additions and 5 deletions

View File

@ -65,14 +65,14 @@ func (this *HooksExecutor) applyEnvironmentVairables(extraVariables ...string) [
}
// executeHook executes a command, and sets relevant environment variables
// combined output & error are printed to gh-ost's standard error.
func (this *HooksExecutor) executeHook(hook string, extraVariables ...string) error {
cmd := exec.Command(hook)
cmd.Env = this.applyEnvironmentVairables(extraVariables...)
if err := cmd.Run(); err != nil {
return log.Errore(err)
}
return nil
combinedOutput, err := cmd.CombinedOutput()
fmt.Fprintln(os.Stderr, string(combinedOutput))
return log.Errore(err)
}
func (this *HooksExecutor) detectHooks(baseName string) (hooks []string, err error) {

View File

@ -2,4 +2,4 @@
# Sample hook file for gh-ost-on-success
echo "$(date) gh-ost-on-success $GH_OST_DATABASE_NAME.$GH_OST_TABLE_NAME" >> /tmp/gh-ost.log
echo "$(date) gh-ost-on-success $GH_OST_DATABASE_NAME.$GH_OST_TABLE_NAME -- this message should show on the gh-ost log"