moved config to config/panda_init.rb, so everything is in one place now

This commit is contained in:
Damien Tanner 2008-06-24 17:30:42 +01:00
Родитель 496f3e0d1d
Коммит c14140dbb6
9 изменённых файлов: 46 добавлений и 58 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -4,5 +4,5 @@ uuid.state
.DS_Store
database.yml
schema.rb
aws.rb
panda_init.rb
videos/*

Просмотреть файл

@ -1,4 +1,4 @@
class Profile < SimpleDB::Base
set_domain 'panda_profiles'
set_domain Panda::Config[:sdb_profiles_domain]
properties :title, :player, :container, :width, :height, :video_codec, :video_bitrate, :fps, :audio_codec, :audio_bitrate, :audio_sample_rate, :position, :updated_at, :created_at
end

Просмотреть файл

@ -1,5 +1,5 @@
class User < SimpleDB::Base
set_domain 'panda_users'
set_domain Panda::Config[:sdb_users_domain]
properties :password, :email, :salt, :crypted_password, :api_key
attr_accessor :password, :password_confirmation

Просмотреть файл

@ -1,5 +1,5 @@
class Video < SimpleDB::Base
set_domain 'panda_videos'
set_domain Panda::Config[:sdb_videos_domain]
properties :filename, :original_filename, :parent, :status, :duration, :container, :width, :height, :video_codec, :video_bitrate, :fps, :audio_codec, :audio_bitrate, :audio_sample_rate, :profile, :profile_title, :player, :encoding_time, :encoded_at, :encoded_at_desc, :updated_at, :created_at
# TODO: state machine for status
@ -226,7 +226,7 @@ class Video < SimpleDB::Base
end
# Add job to queue
Queue.encodings.send_message(self.key)
SQS.get_queue(:name => Panda::Config[:sqs_encoding_queue]).send_message(self.key)
end
# Exceptions

17
config/aws.rb Normal file
Просмотреть файл

@ -0,0 +1,17 @@
SQS.access_key_id = Panda::Config[:access_key_id]
SQS.secret_access_key = Panda::Config[:secret_access_key]
SQS.retry_attempts = 10
SimpleDB::Base.establish_connection!(
:access_key_id => Panda::Config[:access_key_id],
:secret_access_key => Panda::Config[:secret_access_key]
)
AWS::S3::Base.establish_connection!(
:access_key_id => Panda::Config[:access_key_id],
:secret_access_key => Panda::Config[:secret_access_key]
)
class S3VideoObject < AWS::S3::S3Object
set_current_bucket_to Panda::Config[:s3_videos_bucket]
end

Просмотреть файл

@ -1,42 +0,0 @@
ACCESS_KEY_ID = ''
SECRET_ACCESS_KEY = ''
# SQS
SQS.access_key_id = ACCESS_KEY_ID
SQS.secret_access_key = SECRET_ACCESS_KEY
SQS.retry_attempts = 10
class Queue
@@encodings = SQS.get_queue :name => 'panda_encoding'
def self.encodings; @@encodings; end
end
# SimpleDB
# ========
# http://nytimes.rubyforge.org/amazon_sdb/
# SimpleDB::Base.connection.create_domain('panda_videos')
SimpleDB::Base.establish_connection!(
:access_key_id => ACCESS_KEY_ID,
:secret_access_key => SECRET_ACCESS_KEY
)
# S3
# ==
# AWS::S3::Bucket.create("my_bucket")
AWS::S3::Base.establish_connection!(
:access_key_id => ACCESS_KEY_ID,
:secret_access_key => SECRET_ACCESS_KEY
)
# Encoded videos
class S3VideoObject < AWS::S3::S3Object
set_current_bucket_to 'videos.pandastream.com'
end
# Video access logs
# class S3LogObject < AWS::S3::S3Object
# set_current_bucket_to 'panda-logs'
# end

Просмотреть файл

@ -18,6 +18,8 @@ end
# use_orm :activerecord
require "config" / "panda_init"
dependencies 'merb-assets', 'merb-mailer', 'merb_helpers', 'uuid', 'to_simple_xml', 'rog', 'amazon_sdb', 'simple_db', 'retryable', 'activesupport', 'rvideo', 'panda', 'gd_resize', 'map_to_hash'
# Not sure why dependencies won't load AWS::S3
@ -40,16 +42,7 @@ Merb::BootLoader.after_app_loads do
# :auth=>:plain # :plain, :login, :cram_md5, the default is no auth
}
end
Panda::Config.use do |p|
p[:account_name] = "New Bamboo"
p[:api_key] = "f9e69730-16fd-012b-731d-001ec2b5c0e1"
p[:upload_redirect_url] = "http://localhost:4000/videos/$id/done"
p[:state_update_url] = "http://localhost:4000/videos/$id/status"
p[:videos_domain] = "videos.pandastream.com"
p[:storage] = :filesystem # or :s3 # TODO: implement
p[:tmp_video_dir] = Merb.root / "videos"
end
end
EMAIL_SENDER = "Panda <info@pandastream.com>"

Просмотреть файл

@ -0,0 +1,19 @@
require 'panda'
Panda::Config.use do |p|
p[:account_name] = "New Bamboo"
p[:api_key] = "f9e3425-16fd-012b-731d-001ec2b5c0e1"
p[:upload_redirect_url] = "http://localhost:4000/videos/$id/done"
p[:state_update_url] = "http://localhost:4000/videos/$id/status"
p[:videos_domain] = "videos.pandastream.com"
p[:storage] = :filesystem # or :s3 # TODO: implement
p[:tmp_video_dir] = Merb.root / "videos"
p[:access_key_id] = ""
p[:secret_access_key] = ""
p[:s3_videos_bucket] = "videos.pandastream.com"
p[:sqs_encoding_queue] = "panda_encoding"
p[:sdb_videos_domain] = "panda_videos"
p[:sdb_users_domain] = "panda_users"
p[:sdb_profiles_domain] = "panda_profiles"
end

Просмотреть файл

@ -42,11 +42,12 @@ Merb.logger.info 'Encoder awake!'
# Rog.host = PANDA_LOG_SERVER
# Rog.port = 3333
# Merb.logger.info "Panda Encoder app awake"
q = SQS.get_queue(:name => Panda::Config[:sqs_encoding_queue])
loop do
sleep 3
Merb.logger.info "Checking for messages... #{Time.now}"
next unless m = Queue.encodings.receive_message
next unless m = q.receive_message
Merb.logger.info "Got a message!"
key = m.body