angael 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/angael/version.rb +1 -1
- data/lib/angael/worker.rb +17 -10
- metadata +1 -1
data/lib/angael/version.rb
CHANGED
data/lib/angael/worker.rb
CHANGED
@@ -7,16 +7,17 @@ module Angael
|
|
7
7
|
# # Do something interesting, without raising an exception.
|
8
8
|
# end
|
9
9
|
# You can also add some optional behavior by defining the following methods:
|
10
|
-
# #after_fork
|
11
|
-
# #
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
10
|
+
# #after_fork - This is run once, immediately after the child process is forked
|
11
|
+
# #before_exit - This is run once, immediately before the child process exits
|
12
|
+
# #fork_child - This actually does the forking. You can overwrite this method
|
13
|
+
# to do wrap the child process in a block. This is useful for
|
14
|
+
# exception handling. Be sure to actually fork or you may break
|
15
|
+
# something important.
|
16
|
+
# #log - If defined, this will be called at various points of interest
|
17
|
+
# with 1 String as the argument. Log levels are not supported.
|
18
|
+
# #timeout - Number of seconds to wait for the child process to exit after
|
19
|
+
# it is sent SIGINT. If you don't define this method, it waits
|
20
|
+
# 60 seconds.
|
20
21
|
module Worker
|
21
22
|
include ProcessHelper
|
22
23
|
class ChildProcessNotStoppedError < StandardError; end
|
@@ -49,6 +50,12 @@ module Angael
|
|
49
50
|
|
50
51
|
loop do
|
51
52
|
if @interrupted
|
53
|
+
if respond_to?(:before_exit)
|
54
|
+
__debug("Running before exit callback")
|
55
|
+
before_exit
|
56
|
+
__debug("Finished running before exit callback")
|
57
|
+
end
|
58
|
+
|
52
59
|
__info("Child process exiting gracefully")
|
53
60
|
exit 0
|
54
61
|
end
|