-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
105 lines (90 loc) · 2.49 KB
/
Rakefile
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# frozen_string_literal: true
desc 'Start all source containers'
task :all_sources do
%w[via-fluentd-gem via-logging-driver via-td-agent via-td-agent-bit].each do |source|
Rake::Task['start'].invoke(source)
Rake::Task['start'].reenable
end
sh 'docker ps -a --format "table {{.ID}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"'
end
desc 'Clean some generated files'
task :clean do
%w[
.bundle
.cache
coverage
doc
*.gem
Gemfile.lock
.inch
vendor
].each { |f| FileUtils.rm_rf(Dir.glob(f)) }
end
desc 'Stop the entire EFK stack, any additional sources and the minikube cluster'
task :down do
sh './scripts/stop-efk.sh || true'
end
desc 'Start the EFK stack components (including elasticHQ)'
task :efk do
trap('SIGINT') do
puts 'Cancelled EFK stack launch...'
exit
end
sh './scripts/start-efk.sh'
end
desc 'Run ALL the rake tasks: clean test and build'
task everything: %w[down clean style test efk k8s all_sources]
desc 'Start the Kubernetes Minikube components'
task :k8s do
trap('SIGINT') do
puts 'Cancelled Kubernetes cluster launch...'
exit
end
sh './scripts/start-k8s.sh'
end
desc 'Show the logs of the docker-compose stack'
task :logs do
trap('SIGINT') do
puts 'Cancelled log view...'
exit
end
sh 'docker-compose ps'
sh 'docker-compose logs -f'
end
desc 'Start the Prometheus stack component'
task :prometheus do
trap('SIGINT') do
puts 'Cancelled Prometheus stack launch...'
exit
end
sh './scripts/start-prometheus.sh'
end
desc 'Stop the entire EFK stack, additional sources, minikube and then delete all efk_* images'
task :purge do
Rake::Task['down'].invoke
sh 'docker image ls --quiet --filter \'reference=efk_*:*\' | xargs docker rmi -f'
sh 'docker volume prune -f'
end
desc 'Restart a Docker container; port is optional, if supplied will wait for port to be available before tailing logs'
task :restart, [:name, :port] do |_task, args|
trap('SIGINT') do
exit
end
sh "./scripts/restart-container.sh #{args[:name]} #{args[:port]}"
end
desc 'Run Rubocop style checks'
task :rubocop do
sh 'bundle exec rubocop'
end
desc 'Start 1..n source containers'
task :start, :source do |_task, args|
sh "./scripts/start-source.sh #{args[:source]}"
end
desc 'Run all style checks'
task style: %w[rubocop]
desc 'Run all the tests'
task :test do
sh 'source .envrc && bundle install && bundle exec rspec'
end
desc 'Bring up the EFK stack with Kubernetes and all the sources'
task up: %w[down clean efk k8s all_sources]