hive-runner 2.1.26 → 2.1.27
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/lib/hive/device.rb +22 -15
- data/lib/hive/worker.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3302ae2a64590d9f205a92748ab4dd15168af0f
|
4
|
+
data.tar.gz: 3bde86d13078501ca242ca19ae155cdf587145c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06537e131a338ad1688c5ce7f98b67f6876222a2dcab417e2d071f58a99b726c0704a32415eeba8f17467b917284f8f8e14dfc69a8fda770f77a7a02f825fa58
|
7
|
+
data.tar.gz: cd8d1db47eb7bdcf61aa8d8ea8ee524f527427e1a72abfce90f76413b8044618a67ff70bd0596cc292f9b3e1114105deba1c7aa82ed16684be33ce8e105f6ce6
|
data/lib/hive/device.rb
CHANGED
@@ -34,24 +34,31 @@ module Hive
|
|
34
34
|
|
35
35
|
# Terminate the worker process
|
36
36
|
def stop
|
37
|
-
|
37
|
+
protect_file = File.expand_path("#{@worker_pid}.protect", PIDS_DIRECTORY)
|
38
|
+
Hive.logger.debug("Checking for protected file: #{protect_file}")
|
39
|
+
if File.exists? File.expand_path("#{@worker_pid}.protect", PIDS_DIRECTORY)
|
40
|
+
Hive.logger.debug("PID #{@worker_pid} is protected")
|
41
|
+
false
|
42
|
+
else
|
43
|
+
@stop_count = @stop_count.nil? ? 0 : @stop_count + 1
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
if self.running?
|
46
|
+
if @stop_count < 30
|
47
|
+
Hive.logger.info("Attempting to terminate process #{@worker_pid} [#{@stop_count}]")
|
48
|
+
Process.kill 'TERM', @worker_pid
|
49
|
+
else
|
50
|
+
Hive.logger.info("Killing process #{@worker_pid}")
|
51
|
+
Process.kill 'KILL', @worker_pid if self.running?
|
52
|
+
end
|
46
53
|
end
|
47
|
-
end
|
48
54
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
if self.running?
|
56
|
+
false
|
57
|
+
else
|
58
|
+
@worker_pid = nil
|
59
|
+
@stop_count = nil
|
60
|
+
true
|
61
|
+
end
|
55
62
|
end
|
56
63
|
end
|
57
64
|
|
data/lib/hive/worker.rb
CHANGED
@@ -8,6 +8,7 @@ require 'hive/messages'
|
|
8
8
|
require 'hive/port_allocator'
|
9
9
|
require 'code_cache'
|
10
10
|
require 'res'
|
11
|
+
require 'fileutils'
|
11
12
|
|
12
13
|
module Hive
|
13
14
|
# The generic worker class
|
@@ -249,7 +250,9 @@ module Hive
|
|
249
250
|
# Diagnostics function to be extended in child class, as required
|
250
251
|
def diagnostics
|
251
252
|
retn = true
|
253
|
+
protect
|
252
254
|
retn = @diagnostic_runner.run if !@diagnostic_runner.nil?
|
255
|
+
unprotect
|
253
256
|
@log.info('Diagnostics failed') if not retn
|
254
257
|
status = device_status
|
255
258
|
status = set_device_status('happy') if status == 'busy'
|
@@ -500,5 +503,18 @@ module Hive
|
|
500
503
|
def hive_mind_device_identifiers
|
501
504
|
{ id: @device_id }
|
502
505
|
end
|
506
|
+
|
507
|
+
private
|
508
|
+
def protect
|
509
|
+
@protect_file = File.expand_path("#{Process.pid}.protect", PIDS_DIRECTORY)
|
510
|
+
@log.debug("Protecting worker with #{@protect_file}")
|
511
|
+
FileUtils.touch @protect_file
|
512
|
+
end
|
513
|
+
|
514
|
+
def unprotect
|
515
|
+
@log.debug("Unprotecting worker with #{@protect_file}")
|
516
|
+
File.unlink @protect_file if @protect_file
|
517
|
+
@protect_file = nil
|
518
|
+
end
|
503
519
|
end
|
504
520
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hive-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Haig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chamber
|