Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
Fix pilot,yt
Browse files Browse the repository at this point in the history
  • Loading branch information
JustHumanz committed Sep 21, 2021
1 parent 61ed475 commit a226f2a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
9 changes: 7 additions & 2 deletions service/livestream/youtube/checker/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
c := cron.New()
c.Start()
c.AddFunc(config.CheckPayload, GetPayload)
c.AddFunc(config.YoutubePrivateSlayer, CheckPrivate)
//c.AddFunc(config.YoutubePrivateSlayer, CheckPrivate) //TODO make new service for private slayer
c.AddFunc("0 */2 * * *", func() {
engine.ExTknList = nil
})
Expand Down Expand Up @@ -137,7 +137,7 @@ func ReqRunningJob(client pilot.PilotServiceClient) {
if res.Run {
log.WithFields(log.Fields{
"Service": ModuleState,
"Running": false,
"Running": true,
}).Info(res.Message)

YoutubeChecker.Run()
Expand All @@ -150,6 +150,11 @@ func ReqRunningJob(client pilot.PilotServiceClient) {
"Service": ModuleState,
"Running": false,
}).Info("reporting job was done")
} else {
log.WithFields(log.Fields{
"Service": ModuleState,
"Running": false,
}).Info(res.Message)
}

YoutubeChecker.Counter++
Expand Down
17 changes: 17 additions & 0 deletions service/pilot/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ func (s *Server) isYtCheckerRunning() bool {
return false
}

var ModuleWatcher = make(map[string]int)

func (s *Server) RunModuleJob(ctx context.Context, in *ServiceMessage) (*RunJob, error) {
for _, v := range s.Modules {
if v.Name == in.Service {
Expand Down Expand Up @@ -171,11 +173,26 @@ func (s *Server) RunModuleJob(ctx context.Context, in *ServiceMessage) (*RunJob,
}).Info("Module request for running job")

if v.Run {
if ModuleWatcher[in.Service] > v.Counter*4 {
log.WithFields(log.Fields{
"Counter": v.CronJob,
"Service": in.Service,
}).Warn("Job running too long,force acc next request")
v.SetRun(false)
ModuleWatcher[in.Service] = 0
return &RunJob{
Run: false,
Message: "Job running too long,force acc next request",
}, nil
}

log.WithFields(log.Fields{
"Counter": v.CronJob,
"Service": in.Service,
}).Warn("Job still running")

ModuleWatcher[in.Service]++

return &RunJob{
Run: false,
Message: "job still running",
Expand Down
2 changes: 1 addition & 1 deletion service/pilot/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var M = []*pilot.ModuleList{
{
Name: config.SpaceBiliBiliModule,
Counter: 1,
CronJob: 12, //every 7 minutes
CronJob: 12, //every 12 minutes
},
{
Name: config.LiveBiliBiliModule,
Expand Down

0 comments on commit a226f2a

Please sign in to comment.