Last active
April 30, 2017 06:16
-
-
Save lalitlogical/4c8c047b95fe45da6ae19d1b59411783 to your computer and use it in GitHub Desktop.
sunspot solr with help of capistrano 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your other configuration i.e. github repo, branch, deploy_to etc | |
......... | |
namespace :deploy do | |
# Your other configuration i.e. start/stop puma/passanger/any other application server | |
...... | |
before :updated, :setup_solr_data_dir do | |
invoke 'solr:symlink' | |
end | |
..... | |
end | |
# Start Stop Reindex SolrDB | |
namespace :solr do | |
%w[start stop].each do |command| | |
desc "#{command} solr" | |
task command do | |
on roles(:app) do | |
within current_path do | |
with rails_env: fetch(:rails_env, 'production') do | |
execute :bundle, "exec rake sunspot:solr:#{command}" | |
end | |
end | |
end | |
end | |
end | |
desc "restart solr" | |
task :restart do | |
invoke 'solr:stop' | |
invoke 'solr:start' | |
end | |
after 'deploy:finished', 'solr:restart' | |
desc "reindex the whole solr database" | |
task :reindex do | |
# Uncomment below, if you want hard reset the indexes | |
# ---> | |
# invoke 'solr:stop' | |
# on roles(:app) do | |
# execute :rm, "-rf #{shared_path}/solr/default/*" | |
# end | |
# invoke 'solr:start' | |
# <--- | |
on roles(:app) do | |
within current_path do | |
with rails_env: fetch(:rails_env, 'production') do | |
info "Reindexing Solr database" | |
execute :bundle, 'exec', :rake, 'sunspot:solr:reindex' | |
end | |
end | |
end | |
end | |
task :symlink do | |
on roles(:app) do | |
unless test "[ -d #{shared_path}/solr/default ]" | |
execute :mv, "#{release_path}/solr/default #{shared_path}/solr" | |
else | |
execute :rm, "-rf #{release_path}/solr/default" | |
execute "ln -s #{shared_path}/solr/default #{release_path}/solr/default" | |
end | |
unless test "[ -d #{release_path}/solr/pids ]" | |
execute "ln -s #{shared_path}/solr/pids/ #{release_path}/solr/pids" | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
production: | |
solr: | |
hostname: localhost | |
port: 8983 | |
log_level: WARNING | |
# path: /solr/production | |
# read_timeout: 2 | |
# open_timeout: 0.5 | |
staging: | |
solr: | |
hostname: localhost | |
port: 8983 | |
log_level: WARNING | |
# path: /solr/staging | |
# read_timeout: 2 | |
# open_timeout: 0.5 | |
development: | |
solr: | |
hostname: localhost | |
port: 8982 | |
log_level: INFO | |
path: /solr/development | |
test: | |
solr: | |
hostname: localhost | |
port: 8981 | |
log_level: WARNING | |
path: /solr/test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment