This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
260 lines (205 loc) · 5.35 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
require 'rubygems'
begin
require 'byebug' if ENV['debug'] == 'true'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
# Ignore LoadError
end
begin
require 'sshkit'
require 'sshkit/dsl'
require 'io/console'
$:.unshift File.dirname(__FILE__)
$:.unshift File.dirname(__FILE__) + '/lib'
Dir['lib/**/*.rb'].each { |file| require file }
rescue LoadError => exception
puts "Error: #{exception}"
exit 1
end
desc 'List configured servers'
task :list_servers do
run_locally do
manager = LiskRake::ServerManager.new(self)
manager.list
end
end
desc 'Add servers to config'
task :add_servers do
run_locally do
manager = LiskRake::ServerManager.new(self)
manager.add
end
Rake::Task['list_servers'].invoke
end
desc 'Edit servers within config'
task :edit_servers do
run_locally do
manager = LiskRake::ServerManager.new(self)
manager.edit
end
Rake::Task['list_servers'].invoke
end
desc 'Remove servers from config'
task :remove_servers do
run_locally do
manager = LiskRake::ServerManager.new(self)
manager.remove
end
Rake::Task['list_servers'].invoke
end
desc 'Add your public ssh key'
task :add_key do
each_server do |node, deps|
deps.check_local('ssh', 'ssh-copy-id', 'ssh-keygen')
run_locally do
manager = LiskRake::KeyManager.new(self)
manager.add(node.server)
end
end
end
desc 'Log into servers directly'
task :log_into do
each_server do |node, deps|
deps.check_local('ssh')
run_locally do
manager = LiskRake::ServerManager.new(self)
manager.log_into(node.server)
end
end
end
desc 'Install dependencies'
task :install_deps do
puts 'Installing dependencies...'
on_each_server do |node, deps|
installer = LiskRake::ServerInstaller.new(self, node, deps)
installer.install
end
end
desc 'Install lisk nodes'
task :install_nodes do
puts 'Installing lisk nodes...'
on_each_server do |node, deps|
deps.check_remote('bash', 'curl', 'unzip')
installer = LiskRake::NodeInstaller.new(self, node)
installer.install
end
end
desc 'Install dependencies and lisk nodes'
task :install_all do
Rake::Task['install_deps'].invoke
Rake::Task['install_nodes'].invoke
end
desc 'Uninstall lisk nodes'
task :uninstall_nodes do
puts 'Uninstalling lisk nodes...'
on_each_server do |node, deps|
deps.check_remote('bash', 'lisk')
installer = LiskRake::NodeInstaller.new(self, node)
installer.uninstall
end
end
desc 'Clean logs on each server'
task :clean_logs do
puts 'Cleaning logs...'
on_each_server do |node, deps|
deps.check_remote('bash', 'lisk')
manager = LiskRake::LogManager.new(self, node)
manager.clean
end
end
desc 'Download logs from each server'
task :download_logs do
puts 'Downloading logs...'
on_each_server do |node, deps|
deps.check_remote('bash', 'lisk')
manager = LiskRake::LogManager.new(self, node)
manager.download
end
end
desc 'Start lisk nodes'
task :start_nodes do
puts 'Starting lisk nodes...'
on_each_server do |node, deps|
deps.check_remote('bash', 'lisk')
manager = LiskRake::NodeManager.new(self, node)
manager.start
end
end
desc 'Restart lisk nodes'
task :restart_nodes do
puts 'Restarting lisk nodes...'
on_each_server do |node, deps|
deps.check_remote('bash', 'lisk')
manager = LiskRake::NodeManager.new(self, node)
manager.restart
end
end
desc 'Rebuild lisk nodes (using new blockchain only)'
task :rebuild_nodes do
puts 'Rebuilding lisk nodes...'
on_each_server do |node, deps|
deps.check_remote('bash', 'curl', 'lisk')
installer = LiskRake::NodeInstaller.new(self, node)
installer.rebuild
end
end
desc 'Reinstall lisk nodes (keeping blockchain and config intact)'
task :reinstall_nodes do
puts 'Reinstalling lisk nodes...'
on_each_server do |node, deps|
deps.check_remote('bash', 'curl', 'lisk')
installer = LiskRake::NodeInstaller.new(self, node)
installer.reinstall
end
end
desc 'Stop lisk nodes'
task :stop_nodes do
puts 'Stopping lisk nodes...'
on_each_server do |node, deps|
deps.check_remote('bash', 'lisk')
manager = LiskRake::NodeManager.new(self, node)
manager.stop
end
end
desc 'Start forging on lisk nodes'
task :start_forging do
puts 'Starting forging...'
on_each_server do |node, deps|
deps.check_remote('bash', 'curl', 'lisk')
manager = LiskRake::ForgingManager.new(self, node)
manager.start
end
Rake::Task['check_nodes'].invoke
end
desc 'Stop forging on lisk nodes'
task :stop_forging do
puts 'Stopping forging...'
on_each_server do |node, deps|
deps.check_remote('bash', 'curl', 'lisk')
manager = LiskRake::ForgingManager.new(self, node)
manager.stop
end
Rake::Task['check_nodes'].invoke
end
desc 'Check status of lisk nodes'
task :check_nodes do
puts 'Checking nodes...'
LiskRake::Report.run do |report|
on_each_server do |node, deps|
deps.check_remote('bash', 'curl', 'lisk')
api = LiskRake::NodeInspector.new(self, node)
api.node_status { |json| report[node.key] = json }
end
end
end
desc 'Withdraw funds from lisk nodes'
task :withdraw_funds do
puts 'Withdrawing funds...'
recipient = LiskRake::Recipient.new
exit unless recipient.get_address
on_each_server do |node, deps|
deps.check_remote('bash', 'curl', 'lisk')
LiskRake::Withdrawal.withdraw(self, node, recipient)
end
end