diff --git a/bin/delayed_job b/bin/delayed_job new file mode 100755 index 0000000..edf1959 --- /dev/null +++ b/bin/delayed_job @@ -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 diff --git a/config/application.rb b/config/application.rb index 697ca01..ec0739c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -22,7 +22,8 @@ module Wrestling #Add Bootstrap SAAS to asset pipeline config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif) + config.active_job.queue_adapter = :delayed_job end - config.active_job.queue_adapter = :delayed_job + end diff --git a/db/migrate/20150209154145_create_delayed_jobs.rb b/db/migrate/20150209154145_create_delayed_jobs.rb new file mode 100644 index 0000000..27fdcf6 --- /dev/null +++ b/db/migrate/20150209154145_create_delayed_jobs.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index d9bc401..8f8c713 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,16 +11,32 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150206025407) do +ActiveRecord::Schema.define(version: 20150209154145) do - create_table "matches", force: true do |t| + 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" + + create_table "matches", force: :cascade do |t| t.integer "r_id" t.integer "g_id" t.text "g_stat" t.text "r_stat" t.integer "winner_id" - t.string "win_type" - t.string "score" + t.string "win_type", limit: 255 + t.string "score", limit: 255 t.datetime "created_at" t.datetime "updated_at" t.integer "tournament_id" @@ -29,41 +45,41 @@ ActiveRecord::Schema.define(version: 20150206025407) do t.integer "boutNumber" end - create_table "mats", force: true do |t| - t.string "name" + create_table "mats", force: :cascade do |t| + t.string "name", limit: 255 t.integer "tournament_id" t.datetime "created_at" t.datetime "updated_at" end - create_table "schools", force: true do |t| - t.string "name" + create_table "schools", force: :cascade do |t| + t.string "name", limit: 255 t.datetime "created_at" t.datetime "updated_at" t.integer "tournament_id" t.integer "score" end - create_table "tournaments", force: true do |t| - t.string "name" - t.string "address" - t.string "director" - t.string "director_email" + create_table "tournaments", force: :cascade do |t| + t.string "name", limit: 255 + t.string "address", limit: 255 + t.string "director", limit: 255 + t.string "director_email", limit: 255 t.datetime "created_at" t.datetime "updated_at" end - create_table "users", force: true do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" + create_table "users", force: :cascade do |t| + t.string "email", limit: 255, default: "", null: false + t.string "encrypted_password", limit: 255, default: "", null: false + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 t.datetime "created_at" t.datetime "updated_at" end @@ -71,15 +87,15 @@ ActiveRecord::Schema.define(version: 20150206025407) do add_index "users", ["email"], name: "index_users_on_email", unique: true add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true - create_table "weights", force: true do |t| + create_table "weights", force: :cascade do |t| t.integer "max" t.datetime "created_at" t.datetime "updated_at" t.integer "tournament_id" end - create_table "wrestlers", force: true do |t| - t.string "name" + create_table "wrestlers", force: :cascade do |t| + t.string "name", limit: 255 t.integer "school_id" t.integer "weight_id" t.integer "seed" @@ -88,7 +104,7 @@ ActiveRecord::Schema.define(version: 20150206025407) do t.datetime "updated_at" t.integer "season_win" t.integer "season_loss" - t.string "criteria" + t.string "criteria", limit: 255 t.integer "poolNumber" t.boolean "extra" end diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..a4b13ba --- /dev/null +++ b/notes.txt @@ -0,0 +1,2 @@ +run delayed jobs in dev +rake jobs:work \ No newline at end of file