From adc9532e75b17480b71d6716d1680a384e698276 Mon Sep 17 00:00:00 2001 From: Damien Tanner Date: Tue, 24 Jun 2008 00:10:58 +0100 Subject: [PATCH] logging setup of ec2 instance. removed raw video s3 bucket requirement - everything goes in the one videos bucket now --- README_EC2 | 14 ++++++++++++++ app/models/video.rb | 21 ++++----------------- app/views/videos/form.html.erb | 2 +- config/aws.rb.example | 4 ---- 4 files changed, 19 insertions(+), 22 deletions(-) create mode 100644 README_EC2 diff --git a/README_EC2 b/README_EC2 new file mode 100644 index 0000000..721e5d1 --- /dev/null +++ b/README_EC2 @@ -0,0 +1,14 @@ +Panda on EC2 +============ + +Launch the AMI +-------------- +ec2-run-instances ami-5538dd3c -k pv-keypair + +cd /usr/local/panda +git clone git@github.com:newbamboo/panda.git + +Create buckets, domains and queues +---------------------------------- + +You'll need two S3 buckets, one encoded videos (tip: name this a domain such videos.pandastream.com and you can setup a CNAME to S3) another to keep the raw video files in (currently saved with private access only) \ No newline at end of file diff --git a/app/models/video.rb b/app/models/video.rb index 7827b1f..ff7f2a1 100644 --- a/app/models/video.rb +++ b/app/models/video.rb @@ -120,7 +120,7 @@ class Video < SimpleDB::Base # S3 # == - def upload_encoding_to_s3 + def upload_to_s3 begin retryable(:tries => 5) do S3VideoObject.store(self.filename, File.open(self.tmp_filepath), :access => :public_read) @@ -130,24 +130,11 @@ class Video < SimpleDB::Base end end - def upload_raw_to_s3 - Rog.log :info, "#{self.key}: Uploading video to S3" - - begin - retryable(:tries => 5) do - S3RawVideoObject.store(self.filename, File.open(self.tmp_filepath), :access => :private) - end - rescue - Rog.log :info, "#{self.key}: Error with S3" - raise - end - end - def fetch_from_s3 begin retryable(:tries => 5) do open(self.tmp_filepath, 'w') do |file| - S3RawVideoObject.stream(self.filename) {|chunk| file.write chunk} + S3VideoObject.stream(self.filename) {|chunk| file.write chunk} end end rescue @@ -180,7 +167,7 @@ class Video < SimpleDB::Base def process self.valid? self.read_metadata - self.upload_raw_to_s3 + self.upload_to_s3 self.add_to_queue end @@ -422,7 +409,7 @@ class Video < SimpleDB::Base Merb.logger.info "Success encoding #{encoding.filename}. Uploading to S3." Merb.logger.info "Uploading #{encoding.filename}" - encoding.upload_encoding_to_s3 + encoding.upload_to_s3 encoding.capture_thumbnail_and_upload_to_s3 FileUtils.rm encoding.tmp_filepath diff --git a/app/views/videos/form.html.erb b/app/views/videos/form.html.erb index 9068927..390824a 100644 --- a/app/views/videos/form.html.erb +++ b/app/views/videos/form.html.erb @@ -16,7 +16,7 @@ function objToString(o) { }; // bind form using 'ajaxForm' - // $('#upload').ajaxForm(options); + $('#upload').ajaxForm(options); }); // pre-submit callback diff --git a/config/aws.rb.example b/config/aws.rb.example index 367bad2..21a501b 100644 --- a/config/aws.rb.example +++ b/config/aws.rb.example @@ -12,10 +12,6 @@ class Queue end end -# Unencoded videos -class S3RawVideoObject < AWS::S3::S3Object - set_current_bucket_to 'panda_raw' -end # Encoded videos class S3VideoObject < AWS::S3::S3Object set_current_bucket_to 'videos.pandastream.com' # allows nice urls like http://videos.pandastream.com/video.flv