lib/fingercap/configurations/recorder.rb in fingercap-0.4.1 vs lib/fingercap/configurations/recorder.rb in fingercap-0.4.3

- old
+ new

@@ -1,11 +1,8 @@ require 'fingercap/recipes' require 'fingercap/persistant_directory' -gem 'thinking-sphinx' -require 'thinking_sphinx/deploy/capistrano' - Capistrano::Configuration.instance(:must_exist).load do def _instances if ENV['INSTANCE'] [ENV['INSTANCE']] elsif ENV['INSTANCES'] @@ -33,10 +30,11 @@ set :domain, primary_instance role :app, *instances role :web, *instances role :db, primary_instance, :primary => true + role :master, primary_instance set :remote_secure_key_file, '/home/deploy/.ssh/secure.key' set :remote_ssh_options, "-o 'StrictHostKeyChecking no' -i #{remote_secure_key_file}" if variables[:deploy_key_file] @@ -113,17 +111,38 @@ end end namespace :sphinx do desc "Stop Sphinx" - task :stop do - run "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; rake thinking_sphinx:stop RAILS_ENV=production; fi" + task :stop, :roles => :master do + config_file = "#{current_path}/config/production.sphinx.conf" + sudo "touch #{config_file}" + sudo "chown app:app #{config_file}" + sudo "chown app:app #{current_path}/log" + run "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo -u app rake thinking_sphinx:stop RAILS_ENV=production; fi" end + desc "Perform additional configuration for the search daemon" + task :configure, :roles => :master do + config_file = "#{current_path}/config/environments/production.rb" + new_config_file = "#{current_path}/config/environments/production.rb.tmp" + run "cat #{config_file} | sed 's/ThinkingSphinx\..*//' > #{new_config_file}" + run "mv #{new_config_file} #{config_file}" + + config_file = "#{current_path}/config/sphinx.yml" + new_config_file = "#{current_path}/config/sphinx.yml.tmp" + run "cat #{config_file} | sed 's/address:.*/address: 0.0.0.0/' > #{new_config_file}" + run "mv #{new_config_file} #{config_file}" + end + desc "Start the search daemon" - task :start do - thinking_sphinx.configure - thinking_sphinx.start + task :start, :roles => :master do + config_file = "#{current_path}/config/production.sphinx.conf" + sudo "touch #{config_file}" + sudo "chown app:app #{config_file}" + sudo "chown app:app #{current_path}/log" + run "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo -u app rake thinking_sphinx:configure RAILS_ENV=production; fi" + run "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo -u app rake thinking_sphinx:start RAILS_ENV=production; fi" end end namespace :tunnel do PID_FILE = '/var/run/ssh-tunnel.pid' \ No newline at end of file