main_loop 0.1.2.16854 → 0.1.3.16874

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e7882193fa7169dcb0cb7d20439c0b2d00b5663c05608240d73b135754310df
4
- data.tar.gz: 96388a14238af3e46e4dba412de145d62802fb3074512fd09d4ca476336c302e
3
+ metadata.gz: 9ddfd174c8f04a96a34dbddcfe2a4ee59e5747e52ffcd0403d3444c1d0d24356
4
+ data.tar.gz: 5a0ead0ebbc98c8f494eeb5166086e8aeed51c7b276d2deb6bffb2f16d300ebf
5
5
  SHA512:
6
- metadata.gz: b6dff650ca3bd6604cace66a7f0b60f5f440ee45edc8f0da4027efd9bb751d7e116bbc8c8c67df06938080ec7d8d6f3c82262e433387b4d1b22baa3a93afe95f
7
- data.tar.gz: 032d365fe4a39987e340949b5ce77c47178abb68070279e3b21c1165a85b9dd66c1278ca5471d8bf4bb77079316e9f703abb8e0b9548bebe0bdc79f71ca65360
6
+ metadata.gz: 18d1ef3fb48243f552efd0b703687f4b071cf05b2216f33b194aa80f5d343b80ee1035d25193fadbb0cc8582f70508793022a095166f952756f9b493d108b315
7
+ data.tar.gz: ad9e2b8cf3d045550bbfd9b08f8e0997194211a17a7d450d7c00256c604944172c9a6f98efdfedb0323cc81a51109ddf5e27bd3b12d214734b95c7d6351f1b93
@@ -91,6 +91,7 @@ module MainLoop
91
91
 
92
92
  logger.info('All handlers finished exiting...')
93
93
  status = handlers.all?(&:success?) ? @exit_code : 1
94
+ logger.info("Exit: #{status}")
94
95
  exit status
95
96
  end
96
97
  end
@@ -50,6 +50,10 @@ module MainLoop
50
50
  end
51
51
  # :nocov:
52
52
 
53
+ def on_term &block
54
+ @on_term = block
55
+ end
56
+
53
57
  # :nocov:
54
58
  def finished?
55
59
  @finished
@@ -29,7 +29,7 @@ module MainLoop
29
29
  end
30
30
 
31
31
  def start_loop_forever(timeout = 0)
32
- wait = [timeout, 10].min
32
+ wait = [[(timeout / 2.5), 5].min, 5].max
33
33
  Timeouter.loop(timeout) do
34
34
  event = @bus.gets(wait)
35
35
  logger.debug("command:#{event}")
@@ -49,7 +49,7 @@ module MainLoop
49
49
  logger.debug("unknown event:#{event}")
50
50
  end
51
51
 
52
- @dispatcher.reap(reap_children)
52
+ @dispatcher.reap(reap_children) rescue nil
53
53
  @dispatcher.tick
54
54
  end
55
55
  end
@@ -43,6 +43,7 @@ module MainLoop
43
43
  else
44
44
  @terminating_at ||= Time.now
45
45
  logger.info "Process[#{name}] send terminate: Pid:#{@pid}"
46
+ @on_term&.call(@pid) rescue nil
46
47
  ::Process.kill('TERM', @pid) rescue nil
47
48
  end
48
49
  end
@@ -22,9 +22,9 @@ module MainLoop
22
22
  logger.info "Thread[#{name}] exited: thread:#{@thread} Status:#{status}"
23
23
  @thread = nil
24
24
  @finished = true
25
- @success = false
26
25
 
27
26
  return if terminating?
27
+ @success = false
28
28
 
29
29
  handle_retry
30
30
  end
@@ -42,7 +42,9 @@ module MainLoop
42
42
  @thread.kill rescue nil
43
43
  else
44
44
  @terminating_at ||= Time.now
45
+ @success = true
45
46
  logger.info "Thread[#{name}] send terminate: thread:#{@thread}"
47
+ @on_term&.call(@thread) rescue nil
46
48
  end
47
49
  end
48
50
 
@@ -1,6 +1,6 @@
1
1
  module MainLoop
2
2
 
3
- VERSION = '0.1.2'.freeze
3
+ VERSION = '0.1.3'.freeze
4
4
 
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: main_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.16854
4
+ version: 0.1.3.16874
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri