Sha256: 9017f35ea8c439175161252490ca2c3d533b438ff447975c4a7fcd467a63716e
Contents?: true
Size: 697 Bytes
Versions: 8
Compression:
Stored size: 697 Bytes
Contents
module FlyAdmin class StopFFmpegJob < ActiveJob::Base queue_as :default def perform(*args) video_ids = Video.where(state: Video::FAILURE_STATE).select(:id).map(&:id) pid_file = "#{Rails.root}/tmp/pids/ffmpeg_pids.pid" if File.exists?(pid_file) File.open(pid_file) do |f| f.each_line do |line| str = /video_(\d+)\ with\ pid:\ (\d+)/.match(line) next unless str video_id = str[1].to_i ffmpeg_pid = str[2].to_i if video_ids.include?(video_id) system("kill -9 #{ffmpeg_pid}") end end end system("rm #{pid_file}") end end end end
Version data entries
8 entries across 8 versions & 1 rubygems