ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

47 lines
1.6 KiB

  1. import { CONFIG } from '@server/initializers/config.js'
  2. import { RunnerJobModel } from '@server/models/runner/runner-job.js'
  3. import { logger, loggerTagsFactory } from '../../helpers/logger.js'
  4. import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js'
  5. import { getRunnerJobHandlerClass } from '../runners/index.js'
  6. import { AbstractScheduler } from './abstract-scheduler.js'
  7. const lTags = loggerTagsFactory('runner')
  8. export class RunnerJobWatchDogScheduler extends AbstractScheduler {
  9. private static instance: AbstractScheduler
  10. protected schedulerIntervalMs = SCHEDULER_INTERVALS_MS.RUNNER_JOB_WATCH_DOG
  11. private constructor () {
  12. super()
  13. }
  14. protected async internalExecute () {
  15. const vodStalledJobs = await RunnerJobModel.listStalledJobs({
  16. staleTimeMS: CONFIG.REMOTE_RUNNERS.STALLED_JOBS.VOD,
  17. types: [ 'vod-audio-merge-transcoding', 'vod-hls-transcoding', 'vod-web-video-transcoding' ]
  18. })
  19. const liveStalledJobs = await RunnerJobModel.listStalledJobs({
  20. staleTimeMS: CONFIG.REMOTE_RUNNERS.STALLED_JOBS.LIVE,
  21. types: [ 'live-rtmp-hls-transcoding' ]
  22. })
  23. for (const stalled of [ ...vodStalledJobs, ...liveStalledJobs ]) {
  24. logger.info('Abort stalled runner job %s (%s)', stalled.uuid, stalled.type, lTags(stalled.uuid, stalled.type))
  25. const Handler = getRunnerJobHandlerClass(stalled)
  26. await new Handler().abort({
  27. runnerJob: stalled,
  28. abortNotSupportedErrorMessage: 'Stalled runner job'
  29. })
  30. }
  31. }
  32. static get Instance () {
  33. return this.instance || (this.instance = new this())
  34. }
  35. }