mimi-signal 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mimi/signal/version.rb +1 -1
- data/lib/mimi/signal.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5fe64779f430f3c23d3e6c227c7dea62aaf0060
|
4
|
+
data.tar.gz: 2df25e8d2ece397bbb6e597424aa2ee5a56ecc45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 655b4b768b371d983551481c14b61989601c37bdbd40809e3b44f9005f555dc1f32b89ef14a24a3a3b932d711019efc05bce7c778e1eaf14988e3121fc7d8c74
|
7
|
+
data.tar.gz: f378105358fe9be373da55e6f2039479ad2b3ae9746d4c58777999acda90e09f3feda96095d86c2bc5940cf36635e4e31db1887e4ed255c589909c4f0faddab2
|
data/lib/mimi/signal/version.rb
CHANGED
data/lib/mimi/signal.rb
CHANGED
@@ -25,14 +25,15 @@ module Mimi
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
+
# Creates a signal handler and installs it.
|
29
|
+
#
|
30
|
+
# @see Mimi::Signal.trap
|
31
|
+
#
|
28
32
|
def initialize(signal, &block)
|
29
33
|
self.class.handlers[signal.to_sym] ||= { old_trap: nil, blocks: [] }
|
30
34
|
self.class.handlers[signal.to_sym][:blocks].push(block)
|
31
35
|
self.class.handlers[signal.to_sym][:old_trap] ||=
|
32
|
-
Kernel.trap(signal)
|
33
|
-
puts "#{self} got signal #{signal}"
|
34
|
-
self.class.queue << signal.to_sym
|
35
|
-
end
|
36
|
+
Kernel.trap(signal) { self.class.queue << signal.to_sym }
|
36
37
|
self.class.start
|
37
38
|
end
|
38
39
|
|
@@ -40,6 +41,11 @@ module Mimi
|
|
40
41
|
#
|
41
42
|
# @param [Array<String,Symbol>] signals
|
42
43
|
#
|
44
|
+
# @example
|
45
|
+
# Mimi::Signal.trap('INT', 'TERM') do
|
46
|
+
# # graceful shutdown
|
47
|
+
# end
|
48
|
+
#
|
43
49
|
def self.trap(*signals, &block)
|
44
50
|
signals.each { |s| new(s, &block) }
|
45
51
|
end
|