zold 0.13.1 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/zold +1 -1
- data/lib/zold/backtrace.rb +36 -0
- data/lib/zold/commands/merge.rb +3 -2
- data/lib/zold/commands/node.rb +11 -3
- data/lib/zold/commands/remote.rb +1 -0
- data/lib/zold/commands/routines/bonuses.rb +2 -5
- data/lib/zold/http.rb +2 -1
- data/lib/zold/node/front.rb +2 -1
- data/lib/zold/remotes.rb +2 -1
- data/lib/zold/verbose_thread.rb +2 -2
- data/lib/zold/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56ce9c058ad3adfea8a2bec57f2d27fb85aa71a8
|
4
|
+
data.tar.gz: 58177571a9f14a1be47390a0a1b4c5c0bbfbd8f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5872e18495a0c45c1218959e4f2dd96ca5a2de4632ce725e4ce74a97bde73627d0a52187c4108b3788dc9974f541522af9e2f8a750ef42188b31d3089a0c6fad
|
7
|
+
data.tar.gz: 121ba02407f26bd00e71127f62de8508bd9bfab724510a148d9e9862ceb3dda218b7d16657fb9a4ec0296415db7d63761b23aa076044d58ca0dc24be602f4eb2
|
data/bin/zold
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Copyright (c) 2018 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
# Backtrace.
|
22
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
23
|
+
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
|
24
|
+
# License:: MIT
|
25
|
+
module Zold
|
26
|
+
# Backtrace of an exception
|
27
|
+
class Backtrace
|
28
|
+
def initialize(error)
|
29
|
+
@error = error
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_s
|
33
|
+
"#{@error.class.name}: #{@error.message}\n#{@error.backtrace.join("\n\t")}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/zold/commands/merge.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
require 'slop'
|
22
22
|
require 'rainbow'
|
23
23
|
require_relative 'args'
|
24
|
+
require_relative '../backtrace'
|
24
25
|
require_relative '../log'
|
25
26
|
require_relative '../id'
|
26
27
|
require_relative '../wallet'
|
@@ -90,8 +91,8 @@ Available options:"
|
|
90
91
|
def merge_one(patch, wallet, name)
|
91
92
|
patch.join(wallet)
|
92
93
|
rescue StandardError => e
|
93
|
-
@log.error("Can't merge a copy coming from #{name}
|
94
|
-
@log.debug(
|
94
|
+
@log.error("Can't merge a copy coming from #{name}: #{e.message}")
|
95
|
+
@log.debug(Backtrace.new(e).to_s)
|
95
96
|
end
|
96
97
|
end
|
97
98
|
end
|
data/lib/zold/commands/node.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
require 'slop'
|
22
22
|
require_relative '../version'
|
23
23
|
require_relative '../score'
|
24
|
+
require_relative '../backtrace'
|
24
25
|
require_relative '../metronome'
|
25
26
|
require_relative '../wallets'
|
26
27
|
require_relative '../remotes'
|
@@ -169,12 +170,16 @@ module Zold
|
|
169
170
|
nohup_log.print("Started process ##{thr.pid} from process ##{Process.pid}: #{cmd}\n")
|
170
171
|
stdin.close
|
171
172
|
until stdout.eof?
|
172
|
-
|
173
|
+
begin
|
174
|
+
line = stdout.gets
|
175
|
+
rescue IOError => e
|
176
|
+
line = Backtrace.new(e).to_s
|
177
|
+
end
|
173
178
|
nohup_log.print(line)
|
174
179
|
end
|
175
180
|
code = thr.value.to_i
|
176
181
|
nohup_log.print("Exit code of process ##{thr.pid} is #{code}: #{cmd}\n")
|
177
|
-
raise
|
182
|
+
raise unless code.zero?
|
178
183
|
end
|
179
184
|
end
|
180
185
|
|
@@ -190,9 +195,12 @@ module Zold
|
|
190
195
|
end
|
191
196
|
myself = File.expand_path($PROGRAM_NAME)
|
192
197
|
loop do
|
193
|
-
|
198
|
+
begin
|
194
199
|
exec("#{myself} #{ARGV.delete_if { |a| a.start_with?('--nohup') }.join(' ')}", nohup_log)
|
195
200
|
exec(opts['nohup-command'], nohup_log)
|
201
|
+
rescue StandardError => e
|
202
|
+
nohup_log.print(Backtrace.new(e).to_s)
|
203
|
+
raise e
|
196
204
|
end
|
197
205
|
end
|
198
206
|
end
|
data/lib/zold/commands/remote.rb
CHANGED
@@ -42,17 +42,14 @@ module Zold
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def exec(_ = 0)
|
45
|
-
sleep(
|
45
|
+
sleep(10 * 60) unless @opts['routine-immediately']
|
46
46
|
raise '--private-key is required to pay bonuses' unless @opts['private-key']
|
47
47
|
raise '--bonus-wallet is required to pay bonuses' unless @opts['bonus-wallet']
|
48
48
|
raise '--bonus-amount is required to pay bonuses' unless @opts['bonus-amount']
|
49
49
|
winners = Remote.new(remotes: @remotes, log: @log, farm: @farm).run(
|
50
50
|
['remote', 'elect', @opts['bonus-wallet'], '--private-key', @opts['private-key']]
|
51
51
|
)
|
52
|
-
if winners.empty?
|
53
|
-
@log.info('No winners elected, won\'t pay any bonuses')
|
54
|
-
return
|
55
|
-
end
|
52
|
+
return if winners.empty?
|
56
53
|
winners.each do |score|
|
57
54
|
Pull.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run(
|
58
55
|
['pull', opts['bonus-wallet']]
|
data/lib/zold/http.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
require 'rainbow'
|
22
22
|
require 'uri'
|
23
23
|
require 'net/http'
|
24
|
+
require_relative 'backtrace'
|
24
25
|
require_relative 'version'
|
25
26
|
require_relative 'score'
|
26
27
|
|
@@ -83,7 +84,7 @@ module Zold
|
|
83
84
|
end
|
84
85
|
|
85
86
|
def body
|
86
|
-
|
87
|
+
Backtrace.new(@ex).to_s
|
87
88
|
end
|
88
89
|
|
89
90
|
def code
|
data/lib/zold/node/front.rb
CHANGED
@@ -25,6 +25,7 @@ require 'sinatra/base'
|
|
25
25
|
require 'webrick'
|
26
26
|
require 'diffy'
|
27
27
|
require 'concurrent'
|
28
|
+
require_relative '../backtrace'
|
28
29
|
require_relative '../version'
|
29
30
|
require_relative '../wallet'
|
30
31
|
require_relative '../log'
|
@@ -203,7 +204,7 @@ module Zold
|
|
203
204
|
status 503
|
204
205
|
e = env['sinatra.error']
|
205
206
|
content_type 'text/plain'
|
206
|
-
|
207
|
+
Backtrace.new(e).to_s
|
207
208
|
end
|
208
209
|
|
209
210
|
private
|
data/lib/zold/remotes.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
require 'csv'
|
22
22
|
require 'uri'
|
23
23
|
require 'fileutils'
|
24
|
+
require_relative 'backtrace'
|
24
25
|
require_relative 'node/farm'
|
25
26
|
require_relative 'atomic_file'
|
26
27
|
|
@@ -157,7 +158,7 @@ module Zold
|
|
157
158
|
error(r[:host], r[:port])
|
158
159
|
errors = errors(r[:host], r[:port])
|
159
160
|
log.info("#{Rainbow("#{r[:host]}:#{r[:port]}").red}: #{e.message}; errors=#{errors}")
|
160
|
-
log.debug(
|
161
|
+
log.debug(Backtrace.new(e).to_s)
|
161
162
|
remove(r[:host], r[:port]) if errors > Remotes::TOLERANCE
|
162
163
|
end
|
163
164
|
end
|
data/lib/zold/verbose_thread.rb
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require_relative 'log'
|
22
|
+
require_relative 'backtrace'
|
22
23
|
|
23
24
|
# Verbose thread.
|
24
25
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -34,8 +35,7 @@ module Zold
|
|
34
35
|
def run(safe = false)
|
35
36
|
yield
|
36
37
|
rescue StandardError => e
|
37
|
-
@log.error(
|
38
|
-
@log.debug(e.backtrace.join("\n\t"))
|
38
|
+
@log.error(Backtrace.new(e).to_s)
|
39
39
|
raise e unless safe
|
40
40
|
end
|
41
41
|
end
|
data/lib/zold/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -321,6 +321,7 @@ files:
|
|
321
321
|
- lib/zold.rb
|
322
322
|
- lib/zold/amount.rb
|
323
323
|
- lib/zold/atomic_file.rb
|
324
|
+
- lib/zold/backtrace.rb
|
324
325
|
- lib/zold/commands/args.rb
|
325
326
|
- lib/zold/commands/calculate.rb
|
326
327
|
- lib/zold/commands/clean.rb
|