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:
parent
d596240099
commit
3cf504d16a
4 changed files with 25 additions and 16 deletions
|
@ -27,8 +27,8 @@ var APIToken string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var selfSyncCmd = &cobra.Command{
|
var selfSyncCmd = &cobra.Command{
|
||||||
Use: "selfsync <youtube_api_key>",
|
Use: "selfsync",
|
||||||
Args: cobra.RangeArgs(1, 1),
|
Args: cobra.RangeArgs(0, 0),
|
||||||
Short: "Publish youtube channels into LBRY network automatically.",
|
Short: "Publish youtube channels into LBRY network automatically.",
|
||||||
Run: selfSync,
|
Run: selfSync,
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ func selfSync(cmd *cobra.Command, args []string) {
|
||||||
util.SendErrorToSlack(err.Error())
|
util.SendErrorToSlack(err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ytAPIKey := args[0]
|
ytAPIKey := os.Getenv("YOUTUBE_API_KEY")
|
||||||
//authToken := args[1]
|
//authToken := args[1]
|
||||||
|
|
||||||
if !util.InSlice(syncStatus, SyncStatuses) {
|
if !util.InSlice(syncStatus, SyncStatuses) {
|
||||||
|
@ -303,15 +303,17 @@ func syncChannels(channelsToSync []APIYoutubeChannel, ytAPIKey string, syncCount
|
||||||
"NotEnoughFunds",
|
"NotEnoughFunds",
|
||||||
"no space left on device",
|
"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) {
|
if util.InSliceContains(err.Error(), fatalErrors) {
|
||||||
return true, errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err)
|
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
|
continue
|
||||||
}
|
}
|
||||||
if s.IsInterrupted() {
|
if s.IsInterrupted() {
|
||||||
|
|
|
@ -49,14 +49,20 @@ func SendToSlack(message string) error {
|
||||||
|
|
||||||
// SendErrorToSlack Sends an error message to the default channel and to the process log.
|
// SendErrorToSlack Sends an error message to the default channel and to the process log.
|
||||||
func SendErrorToSlack(format string, a ...interface{}) error {
|
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)
|
log.Errorln(message)
|
||||||
return sendToSlack(defaultChannel, defaultUsername, ":sos: "+message)
|
return sendToSlack(defaultChannel, defaultUsername, ":sos: "+message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendInfoToSlack Sends an info message to the default channel and to the process log.
|
// SendInfoToSlack Sends an info message to the default channel and to the process log.
|
||||||
func SendInfoToSlack(format string, a ...interface{}) error {
|
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)
|
log.Debugln(message)
|
||||||
return sendToSlack(defaultChannel, defaultUsername, ":information_source: "+message)
|
return sendToSlack(defaultChannel, defaultUsername, ":information_source: "+message)
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount f
|
||||||
if fi.Size() > 2*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 2GB, skipping for now")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = v.triggerThumbnailSave()
|
err = v.triggerThumbnailSave()
|
||||||
|
|
|
@ -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(20 * time.Minute)
|
s.daemon.SetRPCTimeout(40 * time.Minute)
|
||||||
|
|
||||||
WaitForDaemonStart:
|
WaitForDaemonStart:
|
||||||
for {
|
for {
|
||||||
|
@ -257,6 +257,7 @@ func (s *Sync) startWorker(workerNum int) {
|
||||||
":5279: read: connection reset by peer",
|
":5279: read: connection reset by peer",
|
||||||
"no space left on device",
|
"no space left on device",
|
||||||
"NotEnoughFunds",
|
"NotEnoughFunds",
|
||||||
|
"Cannot publish using channel",
|
||||||
}
|
}
|
||||||
if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError {
|
if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError {
|
||||||
s.grp.Stop()
|
s.grp.Stop()
|
||||||
|
@ -271,15 +272,15 @@ func (s *Sync) startWorker(workerNum int) {
|
||||||
"Error in daemon: Cannot publish empty file",
|
"Error in daemon: Cannot publish empty file",
|
||||||
"Error extracting sts from embedded url response",
|
"Error extracting sts from embedded url response",
|
||||||
"Client.Timeout exceeded while awaiting headers)",
|
"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) {
|
if util.InSliceContains(err.Error(), errorsNoRetry) {
|
||||||
log.Println("This error should not be retried at all")
|
log.Println("This error should not be retried at all")
|
||||||
} else if tryCount < s.MaxTries {
|
} 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(), "failed: Not enough funds") ||
|
||||||
strings.Contains(err.Error(), "Error in daemon: Insufficient funds, please deposit additional LBC") ||
|
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")
|
log.Println("waiting for a block and refilling addresses before retrying")
|
||||||
err = s.walletSetup()
|
err = s.walletSetup()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue