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:
parent
9acd4b08c2
commit
920ee956ac
3 changed files with 15 additions and 10 deletions
12
setup.go
12
setup.go
|
@ -41,6 +41,9 @@ func (s *Sync) walletSetup() error {
|
|||
}
|
||||
}
|
||||
log.Debugf("Source channel has %d videos", numOnSource)
|
||||
if numOnSource == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
numPublished, err := s.daemon.NumClaimsInChannel(s.LbryChannelName)
|
||||
if err != nil {
|
||||
|
@ -50,7 +53,7 @@ func (s *Sync) walletSetup() error {
|
|||
|
||||
minBalance := (float64(numOnSource)-float64(numPublished))*(publishAmount+0.1) + channelClaimAmount
|
||||
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
|
||||
}
|
||||
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)) {
|
||||
//lbryum is messing with us or something. restart the daemon
|
||||
//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
|
||||
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")
|
||||
time.Sleep(wait)
|
||||
|
||||
log.Println("Waiting for transaction to be confirmed")
|
||||
return s.waitUntilUTXOsConfirmed()
|
||||
return nil
|
||||
//log.Println("Waiting for transaction to be confirmed")
|
||||
//return s.waitUntilUTXOsConfirmed()
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if fi.Size() > 1*1024*1024*1024 {
|
||||
if fi.Size() > 2*1024*1024*1024 {
|
||||
//delete the video and ignore the error
|
||||
_ = v.delete()
|
||||
return errors.Err("video is bigger than 1GB, skipping for now")
|
||||
|
|
11
ytsync.go
11
ytsync.go
|
@ -159,7 +159,7 @@ func (s *Sync) FullCycle() error {
|
|||
|
||||
log.Infoln("Waiting for daemon to finish starting...")
|
||||
s.daemon = jsonrpc.NewClient("")
|
||||
s.daemon.SetRPCTimeout(5 * time.Minute)
|
||||
s.daemon.SetRPCTimeout(20 * time.Minute)
|
||||
|
||||
WaitForDaemonStart:
|
||||
for {
|
||||
|
@ -188,8 +188,8 @@ WaitForDaemonStart:
|
|||
return nil
|
||||
}
|
||||
func logShutdownError(shutdownErr error) {
|
||||
util.SendToSlackError("error shutting down daemon: %v", shutdownErr)
|
||||
util.SendToSlackError("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR")
|
||||
util.SendErrorToSlack("error shutting down daemon: %v", shutdownErr)
|
||||
util.SendErrorToSlack("WALLET HAS NOT BEEN MOVED TO THE WALLET BACKUP DIR")
|
||||
}
|
||||
|
||||
func (s *Sync) doSync() error {
|
||||
|
@ -256,6 +256,7 @@ func (s *Sync) startWorker(workerNum int) {
|
|||
fatalErrors := []string{
|
||||
":5279: read: connection reset by peer",
|
||||
"no space left on device",
|
||||
"NotEnoughFunds",
|
||||
}
|
||||
if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError {
|
||||
s.grp.Stop()
|
||||
|
@ -283,14 +284,14 @@ func (s *Sync) startWorker(workerNum int) {
|
|||
err = s.walletSetup()
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
}
|
||||
log.Println("Retrying")
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue