Commit a162da019d6f9beb949e7e00d94290bb689d285f
1 parent
873fdd2e
Exists in
master
and in
29 other branches
Fix solr start and stop
Showing
4 changed files
with
12 additions
and
13 deletions
Show diff stats
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +require 'postgresql_attachment_fu' |
config/initializers/postgresql_attachment_fu.rb
@@ -1 +0,0 @@ | @@ -1 +0,0 @@ | ||
1 | -require 'postgresql_attachment_fu' |
lib/tasks/test.rake
@@ -9,7 +9,6 @@ end | @@ -9,7 +9,6 @@ end | ||
9 | task :test do | 9 | task :test do |
10 | ENV['RAILS_ENV'] = 'test' | 10 | ENV['RAILS_ENV'] = 'test' |
11 | Rake::Task['solr:stop'].invoke | 11 | Rake::Task['solr:stop'].invoke |
12 | - Rake::Task['solr:download'].invoke | ||
13 | Rake::Task['solr:start'].invoke | 12 | Rake::Task['solr:start'].invoke |
14 | errors = %w(test:units test:functionals test:integration cucumber selenium test:noosfero_plugins).collect do |task| | 13 | errors = %w(test:units test:functionals test:integration cucumber selenium test:noosfero_plugins).collect do |task| |
15 | begin | 14 | begin |
vendor/plugins/acts_as_solr_reloaded/lib/tasks/solr.rake
@@ -11,15 +11,16 @@ namespace :solr do | @@ -11,15 +11,16 @@ namespace :solr do | ||
11 | if File.exists?(Rails.root + 'vendor/plugins/acts_as_solr_reloaded/solr/start.jar') | 11 | if File.exists?(Rails.root + 'vendor/plugins/acts_as_solr_reloaded/solr/start.jar') |
12 | puts 'Solr already downloaded.' | 12 | puts 'Solr already downloaded.' |
13 | else | 13 | else |
14 | - cd '/tmp' | ||
15 | - sh "wget -c #{SOLR_URL}" | ||
16 | - if !File.directory?("/tmp/#{SOLR_DIR}") | ||
17 | - sh "tar xzf apache-solr-#{SOLR_VERSION}.tgz" | 14 | + Dir.chdir '/tmp' do |
15 | + sh "wget -c #{SOLR_URL}" | ||
16 | + if !File.directory?("/tmp/#{SOLR_DIR}") | ||
17 | + sh "tar xzf apache-solr-#{SOLR_VERSION}.tgz" | ||
18 | + end | ||
19 | + cd "apache-solr-#{SOLR_VERSION}/example" | ||
20 | + cp_r ['../LICENSE.txt', '../NOTICE.txt', 'README.txt', 'etc', 'lib', 'start.jar', 'webapps', 'work'], Rails.root + 'vendor/plugins/acts_as_solr_reloaded/solr', :verbose => true | ||
21 | + cd 'solr' | ||
22 | + cp_r ['README.txt', 'bin', 'solr.xml'], Rails.root + 'vendor/plugins/acts_as_solr_reloaded/solr/solr', :verbose => true | ||
18 | end | 23 | end |
19 | - cd "apache-solr-#{SOLR_VERSION}/example" | ||
20 | - cp_r ['../LICENSE.txt', '../NOTICE.txt', 'README.txt', 'etc', 'lib', 'start.jar', 'webapps', 'work'], Rails.root + 'vendor/plugins/acts_as_solr_reloaded/solr', :verbose => true | ||
21 | - cd 'solr' | ||
22 | - cp_r ['README.txt', 'bin', 'solr.xml'], Rails.root + 'vendor/plugins/acts_as_solr_reloaded/solr/solr', :verbose => true | ||
23 | end | 24 | end |
24 | end | 25 | end |
25 | 26 | ||
@@ -58,11 +59,11 @@ namespace :solr do | @@ -58,11 +59,11 @@ namespace :solr do | ||
58 | exec cmd | 59 | exec cmd |
59 | else | 60 | else |
60 | pid = fork do | 61 | pid = fork do |
62 | + Process.setpgrp | ||
61 | STDERR.close | 63 | STDERR.close |
62 | exec cmd | 64 | exec cmd |
63 | end | 65 | end |
64 | end | 66 | end |
65 | - sleep(5) | ||
66 | File.open(SOLR_PID_FILE, "w"){ |f| f << pid} unless windows | 67 | File.open(SOLR_PID_FILE, "w"){ |f| f << pid} unless windows |
67 | puts "#{ENV['RAILS_ENV']} Solr started successfully on #{SOLR_HOST}:#{SOLR_PORT}, pid: #{pid}." | 68 | puts "#{ENV['RAILS_ENV']} Solr started successfully on #{SOLR_HOST}:#{SOLR_PORT}, pid: #{pid}." |
68 | end | 69 | end |
@@ -78,14 +79,13 @@ namespace :solr do | @@ -78,14 +79,13 @@ namespace :solr do | ||
78 | File.open(SOLR_PID_FILE, "r") do |f| | 79 | File.open(SOLR_PID_FILE, "r") do |f| |
79 | pid = f.readline | 80 | pid = f.readline |
80 | begin | 81 | begin |
81 | - Process.kill('TERM', pid.to_i) | 82 | + Process.kill('TERM', -pid.to_i) |
82 | killed = true | 83 | killed = true |
83 | rescue | 84 | rescue |
84 | puts "Solr could not be found at pid #{pid.to_i}. Removing pid file." | 85 | puts "Solr could not be found at pid #{pid.to_i}. Removing pid file." |
85 | end | 86 | end |
86 | end | 87 | end |
87 | File.unlink(SOLR_PID_FILE) | 88 | File.unlink(SOLR_PID_FILE) |
88 | - Rake::Task["solr:destroy_index"].invoke if ENV['RAILS_ENV'] == 'test' | ||
89 | puts "Solr shutdown successfully." if killed | 89 | puts "Solr shutdown successfully." if killed |
90 | else | 90 | else |
91 | puts "PID file not found at #{SOLR_PID_FILE}. Either Solr is not running or no PID file was written." | 91 | puts "PID file not found at #{SOLR_PID_FILE}. Either Solr is not running or no PID file was written." |