Sha256: 921d63a7591f57b2950d6edfb458e3d8e8cd16586149ae8b396bc780a93f813b

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

# Sphinx recipes
namespace :sphinx do
  
  after "sphinx:setup", "sphinx:setup_monit"
  
  desc "Install sphinx"
  task :install do 
    # Dependencies: gcc-c++
    script_install("sphinx/install.sh.erb")
  end
  
  desc "Setup sphinx for application"
  task :setup do 
    
    sphinx_bin_path = "#{sphinx_prefix}/bin"
    sphinx_conf_path = "#{shared_path}/config/sphinx.conf"
    sphinx_pid_path = "#{shared_path}/pids/searchd.pid"
    
    put load_template("sphinx/sphinx_app.initd.centos.erb", binding), "/tmp/sphinx.initd"

    sudo "install -o root /tmp/sphinx.initd /etc/init.d/sphinx_#{application}"
    
    sudo "/sbin/chkconfig --level 345 sphinx_#{application} on"    
    
    run "mkdir -p #{shared_path}/var/index"    
  end
  
  desc "Create monit configuration for sphinx"
  task :setup_monit do    
    sphinx_pid_path = "#{shared_path}/pids/searchd.pid"
    put load_template("sphinx/sphinx.monitrc.erb", binding), "/tmp/sphinx_#{application}.monitrc"        
    
    sudo "install -o root /tmp/sphinx_#{application}.monitrc /etc/monit/sphinx_#{application}.monitrc"
  end
  
  desc "Update sphinx for application" 
  task :update_code do
    
    rails_root = current_path
    index_root = "#{shared_path}/var/index";
    log_root = "#{shared_path}/log"
    pid_root = "#{shared_path}/pids"
    
    put load_project_template("config/templates/sphinx.conf.erb", binding), "#{shared_path}/config/sphinx.conf"
  end
  
  desc "Rotate sphinx index for application"
  task :rotate_all do
    run "#{sphinx_prefix}/bin/indexer --config #{shared_path}/config/sphinx.conf --rotate --all"
  end
  
  desc "Build sphinx indexes for application"
  task :index_all do
    run "#{sphinx_prefix}/bin/indexer --config #{shared_path}/config/sphinx.conf --all"
  end
  
  desc "Start sphinx"
  task :start do
    # TODO: Monit
    sudo "/sbin/service monit restart sphinx_#{application}"
  end  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capigen-0.1.1 recipes/sphinx.rb
capigen-0.1.2 lib/recipes/sphinx.rb
capigen-0.1.3 lib/recipes/sphinx.rb