Skip to content

Commit 6f8b058

Browse files
committed
uploader: add retry count
1 parent a0609a6 commit 6f8b058

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

engine/config/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ var DefaultConfig = Config{
2828
// tv
2929
DouyinCookie: "default:__ac_nonce=06245c89100e7ab2dd536; __ac_signature=_02B4Z6wo00f01LjBMSAAAIDBwA.aJ.c4z1C44TWAAEx696;",
3030
KuaishouCookie: "did=web_d86297aa2f579589b8abc2594b0ea985",
31+
32+
PostCmdsRetryCount: 2,
3133
}
3234

3335
type Config struct {
@@ -44,6 +46,7 @@ type Config struct {
4446
SplitRestSeconds uint
4547
CommanderPoolSize uint
4648
ParserMonitorRestSeconds uint
49+
PostCmdsRetryCount int
4750

4851
// tv
4952
DouyinCookie string

engine/uploader/uploader.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os/exec"
66
"strings"
77
"sync"
8+
"time"
89

910
"github.com/go-olive/olive/engine/config"
1011
"github.com/sirupsen/logrus"
@@ -56,15 +57,26 @@ func (u *uploader) proc() {
5657
"filepath": u.taskGroup.Filepath,
5758
}).Info("cmd start running")
5859
handler := DefaultTaskMux.MustGetHandler(postCmd.Path)
59-
err := handler.Process(
60-
&Task{
61-
log: u.log,
62-
cfg: u.cfg,
63-
Filepath: u.taskGroup.Filepath,
64-
StopChan: u.stopChan,
65-
Cmd: postCmd,
66-
},
67-
)
60+
61+
retryCnt := u.cfg.PostCmdsRetryCount
62+
var err error
63+
for i := 0; i <= retryCnt; i++ {
64+
if i != 0 {
65+
time.Sleep(time.Minute)
66+
}
67+
err = handler.Process(
68+
&Task{
69+
log: u.log,
70+
cfg: u.cfg,
71+
Filepath: u.taskGroup.Filepath,
72+
StopChan: u.stopChan,
73+
Cmd: postCmd,
74+
},
75+
)
76+
if err == nil {
77+
break
78+
}
79+
}
6880
if err != nil {
6981
u.log.WithFields(logrus.Fields{
7082
"postCmdPath": postCmd.Path,

zarf/tmpl/config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ BiliupEnable = false
1515
CookieFilepath = '/Users/lucas/github/olive/cookies.json'
1616
Threads = 6
1717
MaxBytesPerSecond = 2097152
18+
PostCmdsRetryCount = 2
1819

1920
[[Shows]]
2021
ID = 'a'
@@ -26,4 +27,4 @@ OutTmpl = '[{{ .StreamerName }}][{{ .RoomName }}][{{ now | date "2006-01-02 15-0
2627
Parser = 'flv'
2728
SaveDir = ''
2829
PostCmds = '[{"Path":"oliveshell","Args":["/bin/zsh","-c","echo $FILE_PATH"]},{"Path":"olivebiliup"},{"Path":"olivetrash"}]'
29-
SplitRule = '{"FileSize":2000000000,"Duration":"1h"}'
30+
SplitRule = '{"FileSize":2000000000,"Duration":"1h"}'

0 commit comments

Comments
 (0)