turns out we do need delayed_job
This commit is contained in:
parent
fe578ca3b2
commit
77d69dd2a3
10 changed files with 59 additions and 6 deletions
2
Gemfile
2
Gemfile
|
@ -21,6 +21,8 @@ gem 'snorlax', '~> 0.1.3'
|
|||
gem 'httparty'
|
||||
gem 'sequenced', '~> 2.0.0'
|
||||
gem 'active_model_serializers', '~> 0.8.1'
|
||||
gem 'delayed_job', '~> 4.0.2'
|
||||
gem 'delayed_job_active_record', '~> 4.0.1'
|
||||
|
||||
gem 'paperclip'
|
||||
gem 'aws-sdk', '< 2.0'
|
||||
|
|
|
@ -73,6 +73,11 @@ GEM
|
|||
coffee-script-source (1.10.0)
|
||||
concurrent-ruby (1.0.1)
|
||||
debug_inspector (0.0.2)
|
||||
delayed_job (4.0.6)
|
||||
activesupport (>= 3.0, < 5.0)
|
||||
delayed_job_active_record (4.0.3)
|
||||
activerecord (>= 3.0, < 5.0)
|
||||
delayed_job (>= 3.0, < 4.1)
|
||||
devise (3.5.6)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
|
@ -262,6 +267,8 @@ DEPENDENCIES
|
|||
binding_of_caller
|
||||
cancan
|
||||
coffee-rails
|
||||
delayed_job (~> 4.0.2)
|
||||
delayed_job_active_record (~> 4.0.1)
|
||||
devise
|
||||
dotenv
|
||||
factory_girl_rails
|
||||
|
|
1
Procfile
1
Procfile
|
@ -1,2 +1,3 @@
|
|||
web: bundle exec rails server -p $PORT
|
||||
worker: bundle exec rake jobs:work
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Webhooks::Slack::SynapseAddedToMap < Webhooks::Slack::Base
|
||||
|
||||
def text
|
||||
"\"*#{eventable.synapse.topic1.name}* #{eventable.synapse.desc || '->'} *#{eventable.synapse.topic2.name}*\" was added as a connection to the map *#{view_map_on_metamaps()}*"
|
||||
"\"*#{eventable.mappable.topic1.name}* #{eventable.mappable.desc || '->'} *#{eventable.mappable.topic2.name}*\" was added as a connection to the map *#{view_map_on_metamaps()}*"
|
||||
end
|
||||
|
||||
def attachment_fallback
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
class Webhooks::Slack::TopicAddedToMap < Webhooks::Slack::Base
|
||||
|
||||
def text
|
||||
"New #{eventable.topic.metacode.name} topic *#{eventable.topic.name}* was added to the map *#{view_map_on_metamaps()}*"
|
||||
"New #{eventable.mappable.metacode.name} topic *#{eventable.mappable.name}* was added to the map *#{view_map_on_metamaps()}*"
|
||||
end
|
||||
|
||||
def icon_url
|
||||
eventable.topic.metacode.icon
|
||||
eventable.mappable.metacode.icon
|
||||
end
|
||||
|
||||
def attachment_fallback
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class WebhookSerializer < ActiveModel::Serializer
|
||||
attributes :text, :username #, :attachments #, :icon_url
|
||||
attributes :text, :username, :icon_url #, :attachments
|
||||
end
|
||||
|
|
5
bin/delayed_job
Executable file
5
bin/delayed_job
Executable file
|
@ -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
|
|
@ -10,7 +10,7 @@ Dotenv.load ".env.#{ENV["RAILS_ENV"]}", '.env'
|
|||
|
||||
module Metamaps
|
||||
class Application < Rails::Application
|
||||
|
||||
config.active_job.queue_adapter = :delayed_job
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
|
22
db/migrate/20160313003721_create_delayed_jobs.rb
Normal file
22
db/migrate/20160313003721_create_delayed_jobs.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
class CreateDelayedJobs < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :delayed_jobs, force: true do |table|
|
||||
table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
|
||||
table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
|
||||
table.text :handler, null: false # 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 null: true
|
||||
end
|
||||
|
||||
add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :delayed_jobs
|
||||
end
|
||||
end
|
18
db/schema.rb
18
db/schema.rb
|
@ -11,11 +11,27 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160312235006) do
|
||||
ActiveRecord::Schema.define(version: 20160313003721) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "delayed_jobs", force: :cascade do |t|
|
||||
t.integer "priority", default: 0, null: false
|
||||
t.integer "attempts", default: 0, null: false
|
||||
t.text "handler", null: false
|
||||
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"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree
|
||||
|
||||
create_table "events", force: :cascade do |t|
|
||||
t.string "kind", limit: 255
|
||||
t.integer "eventable_id"
|
||||
|
|
Loading…
Reference in a new issue