Guest User

Untitled

a guest
May 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. fork do
  2. STDOUT.reopen "log/transcode.log", "a"
  3. STDERR.reopen "log/transcode.log", "a"
  4. loop do
  5. begin
  6. # (options, server_name, file, return_url, file_return_location, video_id)
  7. if !ts.read_all([:production, nil, nil, nil, nil, nil, nil, nil, nil, nil]).empty?
  8. message = ts.take([:production, nil, nil, nil, nil, nil, nil, nil, nil, nil])
  9. elsif !ts.read_all([:stage, nil, nil, nil, nil, nil, nil, nil, nil, nil]).empty?
  10. message = ts.take([:stage, nil, nil, nil, nil, nil, nil, nil, nil, nil])
  11. else
  12. message = ts.take([nil, nil, nil, nil, nil, nil, nil, nil, nil, nil])
  13. end
  14. environment, options, server_name, file, return_url, file_return_location, video_id, transcoder_id, user_id, application_name = message
  15. STDOUT.puts "Transcode Options: "
  16. message.each do |option|
  17. STDOUT.puts "\t#{option}"
  18. end
  19. STDOUT.flush
  20. transcoder = Transcoder.new(options, server_name, file, return_url, file_return_location, video_id, transcoder_id, user_id, environment, application_name)
  21. puts transcoder
  22. STDOUT.puts "Starting transcode..."
  23. STDOUT.flush
  24. transcoder.transcode
  25. rescue Interrupt
  26. STDOUT.puts "Shutting down worker"
  27. STDOUT.puts $!
  28. STDOUT.puts $!.backtrace
  29. STDOUT.flush
  30. break
  31. rescue
  32. STDERR.puts "=== #{Time.now} ==="
  33. STDERR.puts $!
  34. STDERR.puts $!.backtrace
  35. STDERR.puts ""
  36. STDERR.flush
  37. end
  38. end
  39. end
Add Comment
Please, Sign In to add comment