Rakefile
1.2 KB
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
#!/usr/bin/env rake
require 'open-uri'
def elasticsearch_development
return ENV["ELASTICSEARCH_DEVELOPMENT"].nil?
end
desc "download elasticsearch"
task :download do
unless File.exists? '/tmp/elasticsearch.deb'
puts "downloading elasticsearch Debian package..."
download = open('https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.5.deb')
IO.copy_stream(download, '/tmp/elasticsearch.deb')
end
end
desc "install elasticsearch"
task :install => :download do
sh 'sudo apt-get install openjdk-7-jdk'
sh 'sudo dpkg -i /tmp/elasticsearch.deb || sudo apt-get install -f'
end
desc "start elasticsearch"
task :start do
if not system 'sudo systemctl start elasticsearch > /dev/null'
Rake::Task['install'].invoke
end
puts "Enable Elasticsearch service"
if elasticsearch_development
sh 'sudo systemctl start elasticsearch >> /dev/null 2>&1'
sh 'sudo systemctl enable elasticsearch >> /dev/null 2>&1'
sleep 10
end
end
desc "stop elasticsearch"
task :stop do
puts "Disable elasticsearch service"
if elasticsearch_development
sh 'sudo systemctl stop elasticsearch >> /dev/null 2>&1'
sh 'sudo systemctl disable elasticsearch >> /dev/null 2>&1'
end
end