| @@ -35,6 +35,9 @@ gem 'sorcery' | |||||
| gem 'will_paginate', '~> 3.0' | gem 'will_paginate', '~> 3.0' | ||||
| gem 'activerecord-postgresql-adapter' | gem 'activerecord-postgresql-adapter' | ||||
| gem 'pg' | gem 'pg' | ||||
| gem 'delayed_job_active_record' | |||||
| gem 'daemons' | |||||
| gem 'workless' | |||||
| group :production do | group :production do | ||||
| gem 'unicorn' | gem 'unicorn' | ||||
| @@ -47,12 +47,20 @@ GEM | |||||
| execjs | execjs | ||||
| coffee-script-source (1.4.0) | coffee-script-source (1.4.0) | ||||
| curb (0.7.18) | curb (0.7.18) | ||||
| daemons (1.1.9) | |||||
| debug_inspector (0.0.2) | debug_inspector (0.0.2) | ||||
| delayed_job (3.0.5) | |||||
| activesupport (~> 3.0) | |||||
| delayed_job_active_record (0.4.3) | |||||
| activerecord (>= 2.1.0, < 4) | |||||
| delayed_job (~> 3.0) | |||||
| erubis (2.7.0) | erubis (2.7.0) | ||||
| excon (0.16.10) | |||||
| execjs (1.4.0) | execjs (1.4.0) | ||||
| multi_json (~> 1.0) | multi_json (~> 1.0) | ||||
| faraday (0.8.5) | faraday (0.8.5) | ||||
| multipart-post (~> 1.1) | multipart-post (~> 1.1) | ||||
| fattr (2.2.1) | |||||
| feedzirra (0.0.31) | feedzirra (0.0.31) | ||||
| activesupport (>= 3.0.8) | activesupport (>= 3.0.8) | ||||
| builder (~> 3.0.0) | builder (~> 3.0.0) | ||||
| @@ -70,6 +78,8 @@ GEM | |||||
| activesupport (>= 3.1, < 4.1) | activesupport (>= 3.1, < 4.1) | ||||
| haml (>= 3.1, < 4.1) | haml (>= 3.1, < 4.1) | ||||
| railties (>= 3.1, < 4.1) | railties (>= 3.1, < 4.1) | ||||
| heroku-api (0.3.8) | |||||
| excon (~> 0.16.10) | |||||
| hike (1.2.1) | hike (1.2.1) | ||||
| htmlentities (4.3.1) | htmlentities (4.3.1) | ||||
| httpauth (0.2.0) | httpauth (0.2.0) | ||||
| @@ -132,6 +142,8 @@ GEM | |||||
| rake (10.0.3) | rake (10.0.3) | ||||
| rdoc (3.12.1) | rdoc (3.12.1) | ||||
| json (~> 1.4) | json (~> 1.4) | ||||
| rush (0.6.8) | |||||
| session | |||||
| sass (3.2.5) | sass (3.2.5) | ||||
| sass-rails (3.2.6) | sass-rails (3.2.6) | ||||
| railties (~> 3.2.0) | railties (~> 3.2.0) | ||||
| @@ -139,6 +151,8 @@ GEM | |||||
| tilt (~> 1.3) | tilt (~> 1.3) | ||||
| sax-machine (0.0.20) | sax-machine (0.0.20) | ||||
| nokogiri (> 0.0.0) | nokogiri (> 0.0.0) | ||||
| session (3.1.0) | |||||
| fattr | |||||
| sorcery (0.8.1) | sorcery (0.8.1) | ||||
| bcrypt-ruby (~> 3.0.0) | bcrypt-ruby (~> 3.0.0) | ||||
| oauth (~> 0.4.4) | oauth (~> 0.4.4) | ||||
| @@ -162,6 +176,11 @@ GEM | |||||
| rack | rack | ||||
| raindrops (~> 0.7) | raindrops (~> 0.7) | ||||
| will_paginate (3.0.4) | will_paginate (3.0.4) | ||||
| workless (1.1.2) | |||||
| delayed_job (>= 2.0.7) | |||||
| heroku-api | |||||
| rails | |||||
| rush | |||||
| PLATFORMS | PLATFORMS | ||||
| ruby | ruby | ||||
| @@ -171,6 +190,8 @@ DEPENDENCIES | |||||
| better_errors | better_errors | ||||
| binding_of_caller | binding_of_caller | ||||
| coffee-rails (~> 3.2.1) | coffee-rails (~> 3.2.1) | ||||
| daemons | |||||
| delayed_job_active_record | |||||
| feedzirra | feedzirra | ||||
| haml-rails | haml-rails | ||||
| htmlentities | htmlentities | ||||
| @@ -183,3 +204,4 @@ DEPENDENCIES | |||||
| uglifier (>= 1.0.3) | uglifier (>= 1.0.3) | ||||
| unicorn | unicorn | ||||
| will_paginate (~> 3.0) | will_paginate (~> 3.0) | ||||
| workless | |||||
| @@ -1 +1,2 @@ | |||||
| web: bundle exec unicorn -p $PORT -E $RACK_ENV | web: bundle exec unicorn -p $PORT -E $RACK_ENV | ||||
| worker: bundle exec rake jobs:work | |||||
| @@ -9,7 +9,7 @@ class Feed < ActiveRecord::Base | |||||
| after_create :fetch | after_create :fetch | ||||
| def self.fetch_all | def self.fetch_all | ||||
| Feed.all.each { |f| f.fetch } | |||||
| Feed.all.each { |f| f.delay.fetch } | |||||
| end | end | ||||
| # Fetch and parse feed contents from web | # Fetch and parse feed contents from web | ||||
| @@ -60,5 +60,9 @@ Apollo::Application.configure do | |||||
| # Send deprecation notices to registered listeners | # Send deprecation notices to registered listeners | ||||
| config.active_support.deprecation = :notify | config.active_support.deprecation = :notify | ||||
| # Workless | |||||
| config.after_initialize do | |||||
| Delayed::Job.scaler = :heroku_cedar | |||||
| end | |||||
| end | end | ||||
| @@ -0,0 +1,22 @@ | |||||
| class CreateDelayedJobs < ActiveRecord::Migration | |||||
| def self.up | |||||
| create_table :delayed_jobs, :force => true do |table| | |||||
| table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue | |||||
| table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually. | |||||
| table.text :handler # YAML-encoded string of the object that will do work | |||||
| table.text :last_error # reason for last failure (See Note below) | |||||
| table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. | |||||
| table.datetime :locked_at # Set when a client is working on this object | |||||
| table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) | |||||
| table.string :locked_by # Who is working on this object (if locked) | |||||
| table.string :queue # The name of the queue this job is in | |||||
| table.timestamps | |||||
| end | |||||
| add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority' | |||||
| end | |||||
| def self.down | |||||
| drop_table :delayed_jobs | |||||
| end | |||||
| end | |||||
| @@ -11,7 +11,23 @@ | |||||
| # | # | ||||
| # It's strongly recommended to check this file into your version control system. | # It's strongly recommended to check this file into your version control system. | ||||
| ActiveRecord::Schema.define(:version => 20130320181527) do | |||||
| ActiveRecord::Schema.define(:version => 20130326114555) do | |||||
| create_table "delayed_jobs", :force => true do |t| | |||||
| t.integer "priority", :default => 0 | |||||
| t.integer "attempts", :default => 0 | |||||
| t.text "handler" | |||||
| t.text "last_error" | |||||
| t.datetime "run_at" | |||||
| t.datetime "locked_at" | |||||
| t.datetime "failed_at" | |||||
| t.string "locked_by" | |||||
| t.string "queue" | |||||
| t.datetime "created_at", :null => false | |||||
| t.datetime "updated_at", :null => false | |||||
| end | |||||
| add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" | |||||
| create_table "feeds", :force => true do |t| | create_table "feeds", :force => true do |t| | ||||
| t.string "title" | t.string "title" | ||||
| @@ -29,7 +45,7 @@ ActiveRecord::Schema.define(:version => 20130320181527) do | |||||
| t.integer "layer_id" | t.integer "layer_id" | ||||
| end | end | ||||
| add_index "feeds_layers", ["feed_id", "layer_id"], :name => "index_feeds_layers_on_feed_id_and_layer_id" | |||||
| add_index "feeds_layers", ["feed_id", "layer_id"], :name => "index_feeds_layers_on_feed_id_and_layer_id", :unique => true | |||||
| create_table "layers", :force => true do |t| | create_table "layers", :force => true do |t| | ||||
| t.string "name" | t.string "name" | ||||
| @@ -0,0 +1,5 @@ | |||||
| #!/usr/bin/env ruby | |||||
| require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) | |||||
| require 'delayed/command' | |||||
| Delayed::Command.new(ARGV).daemonize | |||||