Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fork do
- STDOUT.reopen "log/transcode.log", "a"
- STDERR.reopen "log/transcode.log", "a"
- loop do
- begin
- # (options, server_name, file, return_url, file_return_location, video_id)
- if !ts.read_all([:production, nil, nil, nil, nil, nil, nil, nil, nil, nil]).empty?
- message = ts.take([:production, nil, nil, nil, nil, nil, nil, nil, nil, nil])
- elsif !ts.read_all([:stage, nil, nil, nil, nil, nil, nil, nil, nil, nil]).empty?
- message = ts.take([:stage, nil, nil, nil, nil, nil, nil, nil, nil, nil])
- else
- message = ts.take([nil, nil, nil, nil, nil, nil, nil, nil, nil, nil])
- end
- environment, options, server_name, file, return_url, file_return_location, video_id, transcoder_id, user_id, application_name = message
- STDOUT.puts "Transcode Options: "
- message.each do |option|
- STDOUT.puts "\t#{option}"
- end
- STDOUT.flush
- transcoder = Transcoder.new(options, server_name, file, return_url, file_return_location, video_id, transcoder_id, user_id, environment, application_name)
- puts transcoder
- STDOUT.puts "Starting transcode..."
- STDOUT.flush
- transcoder.transcode
- rescue Interrupt
- STDOUT.puts "Shutting down worker"
- STDOUT.puts $!
- STDOUT.puts $!.backtrace
- STDOUT.flush
- break
- rescue
- STDERR.puts "=== #{Time.now} ==="
- STDERR.puts $!
- STDERR.puts $!.backtrace
- STDERR.puts ""
- STDERR.flush
- end
- end
- end
Add Comment
Please, Sign In to add comment