Permalink
Browse files

working with resque

  • Loading branch information...
1 parent 660b030 commit 817c87586e31beb4b8ed1398601bb2d789e28690 @maxwell maxwell committed May 21, 2012
View
@@ -7,7 +7,7 @@ gem 'rails', '3.2.3'
gem 'sqlite3'
-
+gem 'resque'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
@@ -35,6 +35,7 @@ end
gem 'heroku'
group :development do
gem "bootstrapped", :git => 'https://github.com/entropillc/bootstrapped.git'
+ gem 'quiet_assets'
end
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
View
@@ -111,9 +111,13 @@ GEM
netrc (0.7.1)
nokogiri (1.5.2)
polyglot (0.3.3)
+ quiet_assets (1.0.1)
+ railties (~> 3.1)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
+ rack-protection (1.2.0)
+ rack
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
@@ -136,6 +140,14 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
+ redis (2.2.2)
+ redis-namespace (1.0.3)
+ redis (< 3.0.0)
+ resque (1.20.0)
+ multi_json (~> 1.0)
+ redis-namespace (~> 1.0.2)
+ sinatra (>= 0.9.2)
+ vegas (~> 0.1.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.10.0)
@@ -163,6 +175,10 @@ GEM
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
spork (1.0.0rc3)
sprockets (2.1.3)
hike (~> 1.2)
@@ -180,6 +196,8 @@ GEM
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
+ vegas (0.1.11)
+ rack (>= 1.0.0)
xpath (0.1.4)
nokogiri (~> 1.3)
@@ -196,7 +214,9 @@ DEPENDENCIES
heroku
heroku-api
jquery-rails
+ quiet_assets
rails (= 3.2.3)
+ resque
rspec-rails
sass-rails (~> 3.2.3)
spork (= 1.0.0rc3)
View
@@ -4,4 +4,5 @@
require File.expand_path('../config/application', __FILE__)
+require 'resque/tasks'
DiasporaProvisioner::Application.load_tasks
@@ -15,7 +15,7 @@ def create
@heroku_application = HerokuApplication.new(params[:heroku_application])
if @heroku_application.save
- @heroku_application.provision_instance!
+ Resque.enqueue(CreateDiasporaInstance, @heroku_application.id)
redirect_to @heroku_application, :notice => "New App Created!"
else
@@ -1,7 +1,6 @@
class HerokuApplication < ActiveRecord::Base
attr_accessible :none
after_destroy :delete_instance
- # after_create :provision_instance
def pending?
provisioned_at.blank?
@@ -19,8 +18,8 @@ def url
"https://#{name}.herokuapp.com"
end
- def provision_instance
- iHerokuInstance.new(self).create!
+ def provision_instance!
+ HerokuProvisioner.new(Diaspora.new(self)).create!
end
def delete_instance
@@ -1,92 +0,0 @@
-class HerokuInstance
- DIASPORA_DIRECTORY = Rails.root.join('vendor/diaspora')
- ADDONS = ['redistogo:nano']
-
- attr_accessor :app
-
- def initialize(app)
- @app = app
- end
-
- def create!
- response = initialize_app
- @app.provision!(response['name'], response['id'], response['git_url'])
- add_config_vars
- set_up_user_env_compile
- set_up_addons
- push
- migrate
- restart
- end
-
- def destroy!
- client.delete_app(@app.name)
- end
-
- private
-
- def initialize_app
- Rails.logger.info 'initializing app'
- client.post_app('stack' => 'cedar').body
- end
-
- def add_config_vars
- Rails.logger.info 'adding config put_config_vars'
- client.put_config_vars(@app.name, 'HEROKU' => 'true', 'SECRET_TOKEN' => SecureRandom.hex(40))
-
- #s3 for asset_sync
- client.put_config_vars(@app.name, 'AWS_ACCESS_KEY_ID' => ENV['AWS_ACCESS_KEY_ID'],
- 'AWS_SECRET_ACCESS_KEY' => ENV['AWS_SECRET_ACCESS_KEY'],
- 'FOG_DIRECTORY' => ENV['FOG_DIRECTORY'],
- 'FOG_PROVIDER' => ENV['FOG_PROVIDER'],
- 'ASSET_HOST' => "https://#{ENV['FOG_DIRECTORY']}.s3.amazaonaws.com"
- )
-
- end
-
- def set_up_addons
- ADDONS.each do |a|
- Rails.logger.info "Adding #{a}"
- client.post_addon(@app.name, a)
- end
- end
-
- def set_up_user_env_compile
- Rails.logger.info "setting up user env compile"
- system "heroku labs:enable user_env_compile -a #{@app.name}"
- end
-
- def migrate
- Rails.logger.info "migrating app"
- client.post_ps(@app.name, 'run rake db:migate')
- system "heroku run rake db:migrate -a #{@app.name}"
- end
-
- def client
- @client ||= Heroku::API.new(:api_key => ENV['HEROKU_API_KEY'])
- end
-
-
- def push
- with_git do
- Rails.logger.info "pushing repo"
- system 'git push heroku master'
- end
- end
-
- def restart
- client.post_ps_restart(@app.name)
- end
-
-
- def with_git(&block)
- Dir.chdir(DIASPORA_DIRECTORY) do
- system "git remote rm heroku" #double check
- system "git remote add heroku #{@app.git_url}"
- yield
- system "git remote rm heroku"
- end
-
- Rails.logger.info "done with git"
- end
-end
@@ -15,7 +15,7 @@
<tbody>
<% @heroku_applications.each do |heroku_application| %>
<tr>
- <td><%= heroku_application.name %></td>
+ <td><%= link_to heroku_application.name, heroku_application.url, :target => '_blank'%></td>
<td><%= heroku_application.heroku_id %></td>
<td><%= heroku_application.pending? %></td>
<td><%= link_to "Show", heroku_application, :class => 'btn btn-mini btn-primary' %></td>
@@ -25,10 +25,6 @@
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
- <link rel="shortcut icon" href="images/favicon.ico">
- <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
- <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
- <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
</head>
<body>

0 comments on commit 817c875

Please sign in to comment.