-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolr
executable file
·66 lines (50 loc) · 1.38 KB
/
solr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env ruby
# Avoid Invalid gemspec warnings
$stderr = File.open("/dev/null", "w")
require "rubygems"
require "rake"
require "pathname"
require 'net/http'
# Reenable stderr
$stderr = STDERR
Rake.application.init($0)
install_dir = Pathname("~").expand_path
def ping_solr
Net::HTTP.new("localhost", 8983).start do |http|
http.read_timeout = 5
response = http.get("/solr")
end
true
rescue Exception => e
false
end
desc "Start the Apache Solr server process"
task :start do
unless ping_solr
chdir(install_dir + "apache-solr/example") do
sh "nohup java -Xms256M -Xmx1024M -DSTOP.PORT=8079 -DSTOP.KEY=stop -Dsolr.solr.home=#{install_dir}/apache-solr/cms -jar start.jar >> #{install_dir}/apache-solr/cms/logs/server.log 2>&1 &"
end
until ping_solr
puts "Waiting for Solr to start up"
sleep 1
end
puts "Solr is up and running"
end
end
desc "Stop the Apache Solr server process"
task :stop do
if ping_solr
chdir(install_dir + "apache-solr/example") do
sh "java -DSTOP.PORT=8079 -DSTOP.KEY=stop -Dsolr.solr.home=#{install_dir}/apache-solr/cms -jar start.jar --stop >> #{install_dir}/apache-solr/cms/logs/server.log 2>&1"
end
end
end
desc "Status of the Apache Solr server process"
task :status do
if ping_solr
puts "OK: Solr is running"
else
puts "Solr is not running"
end
end
Rake.application.top_level