mirror of https://github.com/stashapp/stash.git
Tweak scraper script error printing (#1107)
This commit is contained in:
parent
714ae541d4
commit
984a0c9247
|
@ -1,10 +1,10 @@
|
|||
package scraper
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -59,6 +59,15 @@ func (s *scriptScraper) runScraperScript(inString string, out interface{}) error
|
|||
return errors.New("Error running scraper script")
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(stderr)
|
||||
go func() { // log errors from stderr pipe
|
||||
for scanner.Scan() {
|
||||
logger.Errorf("scraper: %s", scanner.Text())
|
||||
}
|
||||
}()
|
||||
|
||||
logger.Debugf("Scraper script <%s> started", strings.Join(cmd.Args, " "))
|
||||
|
||||
// TODO - add a timeout here
|
||||
decodeErr := json.NewDecoder(stdout).Decode(out)
|
||||
if decodeErr != nil {
|
||||
|
@ -66,14 +75,10 @@ func (s *scriptScraper) runScraperScript(inString string, out interface{}) error
|
|||
return errors.New("could not unmarshal json: " + decodeErr.Error())
|
||||
}
|
||||
|
||||
stderrData, _ := ioutil.ReadAll(stderr)
|
||||
stderrString := string(stderrData)
|
||||
|
||||
err = cmd.Wait()
|
||||
logger.Debugf("Scraper script finished")
|
||||
|
||||
if err != nil {
|
||||
// error message should be in the stderr stream
|
||||
logger.Errorf("scraper error when running command <%s>: %s", strings.Join(cmd.Args, " "), stderrString)
|
||||
return errors.New("Error running scraper script")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue