namespace :sphinx do
namespace :centos do
desc <<-DESC
Install sphinx.\n
- sphinx_build_options
- Sphinx build options.
-
set :sphinx_build_options, {
:url => "http://www.sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz",
:configure_options => "--with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql
--prefix=\#{sphinx_prefix}"
}
- sphinx_prefix
- Sphinx install prefix
- Defaults to @/usr/local/sphinx@
DESC
task :install do
# Settings
fetch(:sphinx_build_options)
fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
# Install dependencies
yum.install([ "gcc-c++" ])
# Build
build.make_install("sphinx", sphinx_build_options)
end
desc <<-DESC
Setup sphinx for application.
- sphinx_prefix
- Sphinx install prefix
- Defaults to @/usr/local/sphinx@
- sphinx_pid_path
- Directory to sphinx pid
- Defaults to @\#{shared_path}/pids/searchd.pid@
- sphinx_conf_path
- Path to sphinx.conf
- Defaults to @\#{shared_path}/config/sphinx.conf@
- sphinx_index_path
- Path to sphinx indexes
- Defaults to @\#{shared_path}/var/index@
"Source":#{link_to_source(__FILE__)}
DESC
task :setup do
# Settings
fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
fetch_or_default(:sphinx_conf_path, "#{shared_path}/config/sphinx.conf")
fetch_or_default(:sphinx_index_root, "#{shared_path}/var/index")
initscript
# Create app indexes dir
run "mkdir -p #{shared_path}/var/index"
end
desc "Setup sphinx initscript"
task :initscript do
fetch_or_default(:sphinx_prefix, "/usr/local/sphinx")
fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
fetch_or_default(:sphinx_conf_path, "#{shared_path}/config/sphinx.conf")
fetch_or_default(:sphinx_index_root, "#{shared_path}/var/index")
utils.install_template("sphinx/sphinx_app.initd.centos.erb", "/etc/init.d/sphinx_#{application}")
run_via "/sbin/chkconfig --level 345 sphinx_#{application} on"
end
end
end