Skip to content

Commit

Permalink
Documented the rake tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Duffin authored and Joel Duffin committed Feb 10, 2010
1 parent 18cbad7 commit 7588390
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 71 deletions.
31 changes: 31 additions & 0 deletions README.rdoc
Expand Up @@ -10,4 +10,35 @@ Add rake tasks to your Rakefile

require 'muck_raker/tasks'

== Rake Tasks

muck:raker:sync - Copy muck-raker migrations, solr config files and initializer file into your application.

muck:raker:start - Start muck-raker daemon running continuously. This task forks and then checks for stale feeds every
60 seconds. When a stale feed is detected, it harvests the feed. If resources are added, updated, or deleted, it
indexes the new resources, generates recommendations for the new resources, and generates tags if needed. Once a week
the daemon updates recommendations for all resources and generates new tag clouds.

muck:raker:stop - Stop the muck raker daemon process.

muck:raker:start_redo - Redo everything and quit. This task harvests, updates recommendations for all resources,
generates tags if needed, and generates new tag clouds. It does not fork. It stops after the one pass through.

muck:raker:harvest - Harvest stale feeds. Each feed has a "harvest_interval" that specifies how often the daemon
should harvest it to see if it has changed.. After that time period has elapsed the feed is considered stale. By
default that time period is 1 day.

muck:raker:index - Index new resources, delete resources that were deleted from the database, and update the index
for resources that were updated in the database.

muck:raker:index_redo - Updates the indexes for all resources.

muck:raker:recommend - Incrementally update recommendations (create recommendations for newly harvested records).

muck:raker:recommend_redo - Redo recommendations for all resources.

muck:raker:subjects - Auto-generate tags for newly harvested resources that don't have at least 4.

muck:raker:tag_clouds - Regenerate tag clouds.

Copyright (c) 2009 Tatemae.com, released under the MIT license
142 changes: 71 additions & 71 deletions lib/muck_raker/tasks.rb
Expand Up @@ -17,14 +17,6 @@ def define

namespace :raker do

desc "Import attention data for use in testing."
task :import_attention => :environment do
require 'active_record/fixtures'
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
yml = File.join(RAILS_ROOT, 'db', 'bootstrap', 'attention')
Fixtures.new(Attention.connection,"attention",Attention,yml).insert_fixtures
end

desc "Sync files from muck raker."
task :sync do
path = File.join(File.dirname(__FILE__), *%w[.. ..])
Expand All @@ -35,17 +27,64 @@ def define
puts "Copied muck-raker migrations, solr config files and initializer"
end

def reload_cores
['en', 'es', 'zh-CN', 'fr', 'ja', 'de', 'ru', 'nl'].each{|core|
Net::HTTP.new('127.0.0.1', SOLR_PORT).request_head('/solr/admin/cores?action=RELOAD&core=' + core).value
}
desc "Start muck-raker daemon running continuously."
task :start => :environment do
daemon_task 'daemon'
end

desc "Reload solr indexes."
task :reload_indexes do
require File.expand_path("#{File.dirname(__FILE__)}/../../config/muck_raker_environment")
reload_cores
puts "Reloaded solr indexes"
desc "Stop a raker daemon process."
task :stop => :environment do
file_path = "#{RAKER_PIDS_PATH}/#{ENV['RAILS_ENV']}_pid"
if File.exists?(file_path)
File.open(file_path, "r") do |f|
pid = f.readline
Process.kill('TERM', pid.to_i)
end
File.unlink(file_path)
puts "Raker shutdown successfully."
else
puts "PID file not found at #{file_path}. Either Raker is not running or no PID file was written."
end
end

desc "Redo everything and quit."
task :start_redo => :environment do
daemon_task 'daemon', 'redo'
end

desc "Harvest stale feeds."
task :harvest => :environment do
daemon_task 'harvest'
end

desc "Index new entries."
task :index => :environment do
daemon_task 'index'
end

desc "Re-index all entries."
task :index_redo => :environment do
daemon_task 'index', 'redo'
end

desc "Incrementally update recommendations (create recommendations for newly harvested records)."
task :recommend => :environment do
daemon_task 'recommend'
end

desc "Redo all recommendations."
task :recommend_redo => :environment do
daemon_task 'recommend', 'redo'
end

desc "Auto-generate tags for new entries that don't have at least 4."
task :subjects => :environment do
daemon_task 'subjects'
end

desc "Re-generate tag clouds."
task :tag_clouds => :environment do
daemon_task 'tag_clouds', 'redo'
end

def show_options
Expand Down Expand Up @@ -95,64 +134,25 @@ def daemon_task task = 'all', task_param = nil
end
end

desc "Start muck-raker daemon running continously."
task :start => :environment do
daemon_task 'daemon'
end

desc "Redo everything and quit."
task :start_redo => :environment do
daemon_task 'daemon', 'redo'
end

desc "Harvest stale feeds."
task :harvest => :environment do
daemon_task 'harvest'
end

desc "Index new entries."
task :index => :environment do
daemon_task 'index'
end

desc "Re-index all entries."
task :index_redo => :environment do
daemon_task 'index', 'redo'
end

desc "Incrementally update recommendations (create recommendations for newly harvested records)."
task :recommend => :environment do
daemon_task 'recommend'
end

desc "Redo all recommendations."
task :recommend_redo => :environment do
daemon_task 'recommend', 'redo'
end

desc "Auto-generate tags for new entries that don't have at least 4."
task :subjects => :environment do
daemon_task 'subjects'
desc "Reload solr indexes."
task :reload_indexes do
require File.expand_path("#{File.dirname(__FILE__)}/../../config/muck_raker_environment")
reload_cores
puts "Reloaded solr indexes"
end

desc "Re-generate tag clouds."
task :tag_clouds => :environment do
daemon_task 'tag_clouds', 'redo'
def reload_cores
['en', 'es', 'zh-CN', 'fr', 'ja', 'de', 'ru', 'nl'].each{|core|
Net::HTTP.new('127.0.0.1', SOLR_PORT).request_head('/solr/admin/cores?action=RELOAD&core=' + core).value
}
end

desc "Stop a raker daemon process."
task :stop => :environment do
file_path = "#{RAKER_PIDS_PATH}/#{ENV['RAILS_ENV']}_pid"
if File.exists?(file_path)
File.open(file_path, "r") do |f|
pid = f.readline
Process.kill('TERM', pid.to_i)
end
File.unlink(file_path)
puts "Raker shutdown successfully."
else
puts "PID file not found at #{file_path}. Either Raker is not running or no PID file was written."
end
desc "Import attention data for use in testing."
task :import_attention => :environment do
require 'active_record/fixtures'
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
yml = File.join(RAILS_ROOT, 'db', 'bootstrap', 'attention')
Fixtures.new(Attention.connection,"attention",Attention,yml).insert_fixtures
end

end
Expand Down

0 comments on commit 7588390

Please sign in to comment.