#2150·capistrano

solr is not restart or start on rollback

Author: w3villa-ankitCreated Feb 6, 2024Updated Feb 6, 2024

this is my config

##` namespace :puma do desc 'Create Directories for Puma Pids and Socket' task :make_dirs do on roles(:app) do execute "mkdir #{shared_path}/tmp/sockets -p" execute "mkdir #{shared_path}/tmp/pids -p" end end

before :start, :make_dirs end

namespace :deploy do desc "Make sure local git is in sync with remote." task :check_revision do on roles(:app) do unless git rev-parse HEAD == git rev-parse origin/master puts "WARNING: HEAD is not the same as origin/master" puts "Run git push to sync changes." # exit end end end Rake::Task["sidekiq:quiet"].clear_actions #already handled by sidekiq service

desc 'Initial Deploy' task :initial do on roles(:app) do before 'deploy:restart', 'puma:start' invoke 'deploy' end end

desc 'Update Crontab' task :crontab do on roles(:app), in: :sequence, wait: 5 do set(:whenever_command) { "cd /home/#{fetch(:user)}/#{fetch(:application)}/current && crontab -r && ~/.rvm/bin/rvm default do bundle exec whenever -i #{fetch(:application)}_#{fetch(:stage)} --set environment=#{fetch :rails_env}" } end end

desc "Reindex Solr" task :reindex_solr do on roles(:app),in: :sequence,wait: 5 do execute "bash /home/#{fetch(:user)}/scripts/rsolr.sh" # execute "cd /home/#{fetch(:user)}/#{fetch(:application)}/current && ~/.rvm/bin/rvm default do RAILS_ENV=#{fetch :rails_env} bundle exec rake sunspot:solr:reindex" # execute "cd #{current_path} && RAILS_ENV=#{fetch :rails_env} #{fetch :rvm_binary} #{fetch :rvm_ruby_version} do bundle exec rake sunspot:solr:reindex" end end

desc 'Restart application' task :restart do on roles(:app), in: :sequence, wait: 5 do invoke 'puma:restart' end end desc 'notification messages' task :create_notification do on roles(:app_server), in: :sequence,wait: 5 do within release_path do with rails_env: fetch(:rails_env) do execute :rake, 'notification:create' end end end end

desc 'clear cache' task :clear_cache do on roles(:app), in: :sequence, wait: 5 do within release_path do with rails_env: fetch(:rails_env) do execute :rake, "cache:clear" end end end end

namespace :deploy do task :reindex_solr do # Your reindex_solr tasks end

task :rollback do
  # Your rollback tasks
  invoke 'deploy:reindex_solr'
end

task :restart_solr do
  on roles(:app) do
    # Your Solr restart command
    invoke 'deploy:reindex_solr'
  end
end

end

before :starting, :check_revision after :finishing, :compile_assets after :finishing, :cleanup

after :finishing, :crontab

after :finishing, :restart after :finishing, :reindex_solr after :finishing, :restart_solr after :finishing, :create_notification after :finishing, :clear_cache before 'deploy:starting', 'test:calculation_test_cases' before 'deploy:starting', 'test:brakeman' end

ps aux | grep puma # Get puma pid

kill -s SIGUSR2 pid # Restart puma

kill -s SIGTERM pid # Stop puma

`