mirror of https://bitbucket.org/ausocean/av.git
looper: rc.local adding path, main.go letting finish the play to find stderr before fatal
This commit is contained in:
parent
4690209fd5
commit
6968b973bd
|
@ -69,6 +69,7 @@ func main() {
|
|||
|
||||
// Infinite loop that outputs audio and gathers debug information.
|
||||
var numPlays int
|
||||
var fatal bool
|
||||
for {
|
||||
numPlays++
|
||||
log.Log(logger.Debug, "playing audio", "play number", numPlays)
|
||||
|
@ -91,7 +92,8 @@ func main() {
|
|||
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
log.Log(logger.Fatal, "cmd.Start() for 'play' failed", "error", err.Error())
|
||||
log.Log(logger.Error, "cmd.Start() failed", "error", err.Error())
|
||||
fatal = true
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
@ -107,13 +109,19 @@ func main() {
|
|||
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
log.Log(logger.Fatal, "cmd.Run() for 'play' failed", "error", err.Error())
|
||||
log.Log(logger.Error, "cmd.Run() failed", "error", err.Error())
|
||||
fatal = true
|
||||
}
|
||||
if errStdout != nil || errStderr != nil {
|
||||
log.Log(logger.Fatal, "failed to capture stdout or stderr")
|
||||
log.Log(logger.Error, "failed to capture stdout or stderr")
|
||||
fatal = true
|
||||
}
|
||||
outStr, errStr := string(stdoutBuf.Bytes()), string(stderrBuf.Bytes())
|
||||
log.Log(logger.Debug, "stdout received", "stdout", outStr)
|
||||
log.Log(logger.Debug, "stderr received", "stderr", errStr)
|
||||
|
||||
if fatal == true {
|
||||
log.Log(logger.Fatal, "a fatal error has occured while trying to play (see above)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ set -x # tell sh to display commands before execution
|
|||
PLAYERPATH=/home/pi/go/src/bitbucket.org/ausocean/av/cmd/audio-player/looper
|
||||
cd $PLAYERPATH
|
||||
|
||||
./looper &
|
||||
sudo ./looper -path=/home/pi/example.mp3 &
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue