fix slack logging

add failure cases
change interrupt behavior for fatal errors
bump up timeout to 20 minutes
change max file size to 2GB
remove unnecessary utxo wait
This commit is contained in:
Niko Storni 2018-06-15 17:03:28 -04:00
parent 9acd4b08c2
commit 920ee956ac
3 changed files with 15 additions and 10 deletions

View file

@ -41,6 +41,9 @@ func (s *Sync) walletSetup() error {
} }
} }
log.Debugf("Source channel has %d videos", numOnSource) log.Debugf("Source channel has %d videos", numOnSource)
if numOnSource == 0 {
return nil
}
numPublished, err := s.daemon.NumClaimsInChannel(s.LbryChannelName) numPublished, err := s.daemon.NumClaimsInChannel(s.LbryChannelName)
if err != nil { if err != nil {
@ -50,7 +53,7 @@ func (s *Sync) walletSetup() error {
minBalance := (float64(numOnSource)-float64(numPublished))*(publishAmount+0.1) + channelClaimAmount minBalance := (float64(numOnSource)-float64(numPublished))*(publishAmount+0.1) + channelClaimAmount
if numPublished > numOnSource { if numPublished > numOnSource {
util.SendToSlackError("something is going on as we published more videos than those available on source: %d/%d", numPublished, numOnSource) util.SendErrorToSlack("something is going on as we published more videos than those available on source: %d/%d", numPublished, numOnSource)
minBalance = 1 //since we ended up in this function it means some juice is still needed minBalance = 1 //since we ended up in this function it means some juice is still needed
} }
amountToAdd, _ := decimal.NewFromFloat(minBalance).Sub(balance).Float64() amountToAdd, _ := decimal.NewFromFloat(minBalance).Sub(balance).Float64()
@ -166,7 +169,7 @@ func (s *Sync) waitUntilUTXOsConfirmed() error {
if time.Now().After(origin.Add(15 * time.Minute)) { if time.Now().After(origin.Add(15 * time.Minute)) {
//lbryum is messing with us or something. restart the daemon //lbryum is messing with us or something. restart the daemon
//this could also be a very long block //this could also be a very long block
util.SendToSlackError("We've been waiting UTXOs confirmation for %s... and this isn't normal", time.Now().Sub(origin).String()) util.SendErrorToSlack("We've been waiting UTXOs confirmation for %s... and this isn't normal", time.Now().Sub(origin).String())
} }
wait := 30 * time.Second wait := 30 * time.Second
log.Println("Waiting " + wait.String() + "...") log.Println("Waiting " + wait.String() + "...")
@ -282,6 +285,7 @@ func (s *Sync) addCredits(amountToAdd float64) error {
log.Println("Waiting " + wait.String() + " for lbryum to let us know we have the new transaction") log.Println("Waiting " + wait.String() + " for lbryum to let us know we have the new transaction")
time.Sleep(wait) time.Sleep(wait)
log.Println("Waiting for transaction to be confirmed") return nil
return s.waitUntilUTXOsConfirmed() //log.Println("Waiting for transaction to be confirmed")
//return s.waitUntilUTXOsConfirmed()
} }

View file

@ -211,7 +211,7 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f
if err != nil { if err != nil {
return err return err
} }
if fi.Size() > 1*1024*1024*1024 { if fi.Size() > 2*1024*1024*1024 {
//delete the video and ignore the error //delete the video and ignore the error
_ = v.delete() _ = v.delete()
return errors.Err("video is bigger than 1GB, skipping for now") return errors.Err("video is bigger than 1GB, skipping for now")

View file

@ -159,7 +159,7 @@ func (s *Sync) FullCycle() error {
log.Infoln("Waiting for daemon to finish starting...") log.Infoln("Waiting for daemon to finish starting...")
s.daemon = jsonrpc.NewClient("") s.daemon = jsonrpc.NewClient("")
s.daemon.SetRPCTimeout(5 * time.Minute) s.daemon.SetRPCTimeout(20 * time.Minute)
WaitForDaemonStart: WaitForDaemonStart:
for { for {
@ -188,8 +188,8 @@ WaitForDaemonStart:
return nil return nil
} }
func logShutdownError(shutdownErr error) { func logShutdownError(shutdownErr error) {
util.SendToSlackError("error shutting down daemon: %v", shutdownErr) util.SendErrorToSlack("error shutting down daemon: %v", shutdownErr)
util.SendToSlackError("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR") util.SendErrorToSlack("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR")
} }
func (s *Sync) doSync() error { func (s *Sync) doSync() error {
@ -256,6 +256,7 @@ func (s *Sync) startWorker(workerNum int) {
fatalErrors := []string{ fatalErrors := []string{
":5279: read: connection reset by peer", ":5279: read: connection reset by peer",
"no space left on device", "no space left on device",
"NotEnoughFunds",
} }
if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError { if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError {
s.grp.Stop() s.grp.Stop()
@ -283,14 +284,14 @@ func (s *Sync) startWorker(workerNum int) {
err = s.walletSetup() err = s.walletSetup()
if err != nil { if err != nil {
s.stop.Stop() s.stop.Stop()
util.SendToSlackError("Failed to setup the wallet for a refill: %v", err) util.SendErrorToSlack("Failed to setup the wallet for a refill: %v", err)
break break
} }
} }
log.Println("Retrying") log.Println("Retrying")
continue continue
} }
util.SendToSlackError("Video failed after %d retries, skipping. Stack: %s", tryCount, logMsg) util.SendErrorToSlack("Video failed after %d retries, skipping. Stack: %s", tryCount, logMsg)
} }
} }
break break