remove launch parameter

improve failure handling
adjust slack logging
increase file size in string
increase publish timeout to 40 minutes
This commit is contained in:
Niko Storni 2018-06-17 19:50:59 -04:00
parent d596240099
commit 3cf504d16a
No known key found for this signature in database
GPG key ID: F37FE63398800368
4 changed files with 25 additions and 16 deletions

View file

@ -27,8 +27,8 @@ var APIToken string
func init() {
var selfSyncCmd = &cobra.Command{
Use: "selfsync <youtube_api_key>",
Args: cobra.RangeArgs(1, 1),
Use: "selfsync",
Args: cobra.RangeArgs(0, 0),
Short: "Publish youtube channels into LBRY network automatically.",
Run: selfSync,
}
@ -165,7 +165,7 @@ func selfSync(cmd *cobra.Command, args []string) {
util.SendErrorToSlack(err.Error())
return
}
ytAPIKey := args[0]
ytAPIKey := os.Getenv("YOUTUBE_API_KEY")
//authToken := args[1]
if !util.InSlice(syncStatus, SyncStatuses) {
@ -303,15 +303,17 @@ func syncChannels(channelsToSync []APIYoutubeChannel, ytAPIKey string, syncCount
"NotEnoughFunds",
"no space left on device",
}
//mark video as failed
err2 := setChannelSyncStatus(channelID, StatusFailed)
if err2 != nil {
msg := fmt.Sprintf("Failed setting failed state for channel %s.", lbryChannelName)
err2 = errors.Prefix(msg, err2)
util.SendErrorToSlack(err2.Error())
}
if util.InSliceContains(err.Error(), fatalErrors) {
return true, errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err)
}
//mark video as failed
err := setChannelSyncStatus(channelID, StatusFailed)
if err != nil {
msg := fmt.Sprintf("Failed setting failed state for channel %s. \n@Nikooo777 this requires manual intervention! Exiting...", lbryChannelName)
return s.IsInterrupted(), errors.Prefix(msg, err)
}
continue
}
if s.IsInterrupted() {

View file

@ -49,14 +49,20 @@ func SendToSlack(message string) error {
// SendErrorToSlack Sends an error message to the default channel and to the process log.
func SendErrorToSlack(format string, a ...interface{}) error {
message := fmt.Sprintf(format, a...)
message := format
if len(a) > 0 {
message = fmt.Sprintf(format, a...)
}
log.Errorln(message)
return sendToSlack(defaultChannel, defaultUsername, ":sos: "+message)
}
// SendInfoToSlack Sends an info message to the default channel and to the process log.
func SendInfoToSlack(format string, a ...interface{}) error {
message := fmt.Sprintf(format, a...)
message := format
if len(a) > 0 {
message = fmt.Sprintf(format, a...)
}
log.Debugln(message)
return sendToSlack(defaultChannel, defaultUsername, ":information_source: "+message)
}

View file

@ -214,7 +214,7 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f
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")
return errors.Err("video is bigger than 2GB, skipping for now")
}
err = v.triggerThumbnailSave()

View file

@ -159,7 +159,7 @@ func (s *Sync) FullCycle() error {
log.Infoln("Waiting for daemon to finish starting...")
s.daemon = jsonrpc.NewClient("")
s.daemon.SetRPCTimeout(20 * time.Minute)
s.daemon.SetRPCTimeout(40 * time.Minute)
WaitForDaemonStart:
for {
@ -257,6 +257,7 @@ func (s *Sync) startWorker(workerNum int) {
":5279: read: connection reset by peer",
"no space left on device",
"NotEnoughFunds",
"Cannot publish using channel",
}
if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError {
s.grp.Stop()
@ -271,15 +272,15 @@ func (s *Sync) startWorker(workerNum int) {
"Error in daemon: Cannot publish empty file",
"Error extracting sts from embedded url response",
"Client.Timeout exceeded while awaiting headers)",
"video is bigger than 1GB, skipping for now",
"video is bigger than 2GB, skipping for now",
}
if util.InSliceContains(err.Error(), errorsNoRetry) {
log.Println("This error should not be retried at all")
} else if tryCount < s.MaxTries {
if strings.Contains(err.Error(), "258: txn-mempool-conflict") ||
if strings.Contains(err.Error(), "txn-mempool-conflict") ||
strings.Contains(err.Error(), "failed: Not enough funds") ||
strings.Contains(err.Error(), "Error in daemon: Insufficient funds, please deposit additional LBC") ||
strings.Contains(err.Error(), "64: too-long-mempool-chain") {
strings.Contains(err.Error(), "too-long-mempool-chain") {
log.Println("waiting for a block and refilling addresses before retrying")
err = s.walletSetup()
if err != nil {