servitude 1.0.0 → 1.1.0
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/servitude/server_threaded.rb +26 -6
- data/lib/servitude/version.rb +1 -1
- 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: dce6d48e55e0ea709cbac0ab8bb83576f5d4f855
|
4
|
+
data.tar.gz: c96667392283ea694bd05cdccbfe48a054a40416
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b79ae5973d8b1788a8ff27956081e746bc61bd91f53bab9bd5f509d04994950dd395883a0e87aa8c80b2ce256301805c65632000dfeaa859927d31e16a736a4a
|
7
|
+
data.tar.gz: f0946a59b22f543d219a45c3286ea3c93d6e26ae77080399c10faf137285b9ac231cb726200c64d71a4344fac8decc2fb6c83caeb07f0dd6c5c5a4e8b3c9b470
|
@@ -1,9 +1,12 @@
|
|
1
|
+
require 'celluloid'
|
2
|
+
|
1
3
|
module Servitude
|
2
4
|
module ServerThreaded
|
3
5
|
|
4
6
|
def self.included( base )
|
5
7
|
base.class_eval do
|
6
8
|
after_initialize :initialize_thread
|
9
|
+
after_initialize :initialize_celluloid_logger
|
7
10
|
end
|
8
11
|
end
|
9
12
|
|
@@ -17,21 +20,29 @@ module Servitude
|
|
17
20
|
raise NotImplementedError
|
18
21
|
end
|
19
22
|
|
20
|
-
def with_supervision( &block )
|
23
|
+
def with_supervision( options={}, &block )
|
21
24
|
begin
|
22
25
|
block.call
|
23
26
|
rescue Servitude::SupervisionError
|
24
27
|
# supervisor is restarting actor
|
25
28
|
warn_for_supevision_error
|
26
|
-
|
29
|
+
notify_and_sleep_if_configured
|
27
30
|
retry
|
28
31
|
rescue Celluloid::DeadActorError
|
29
32
|
# supervisor has yet to begin restarting actor
|
30
33
|
warn_for_dead_actor_error
|
31
|
-
|
34
|
+
notify_and_sleep_if_configured
|
32
35
|
retry
|
33
36
|
rescue => e
|
34
|
-
handle_error(
|
37
|
+
handle_error( options, e )
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def notify_and_sleep_if_configured
|
42
|
+
if config.supervision_retry_timeout_in_seconds &&
|
43
|
+
config.supervision_retry_timeout_in_seconds > 0
|
44
|
+
debug "Sleeping for #{config.supervision_retry_timeout_in_seconds}s ..."
|
45
|
+
sleep( config.supervision_retry_timeout_in_seconds )
|
35
46
|
end
|
36
47
|
end
|
37
48
|
|
@@ -43,8 +54,13 @@ module Servitude
|
|
43
54
|
warn "RETRYING due to Celluloid::DeadActorError ..."
|
44
55
|
end
|
45
56
|
|
46
|
-
def handle_error(
|
47
|
-
|
57
|
+
def handle_error( options, e )
|
58
|
+
parts = [[e.class.name, e.message].join( ' ' ), format_backtrace( e.backtrace )]
|
59
|
+
error( parts.join( "\n" ))
|
60
|
+
end
|
61
|
+
|
62
|
+
def format_backtrace( backtrace )
|
63
|
+
" #{backtrace.join "\n "}"
|
48
64
|
end
|
49
65
|
|
50
66
|
# Correctly calls a single supervised actor when the threads configuraiton is set
|
@@ -69,6 +85,10 @@ module Servitude
|
|
69
85
|
Celluloid::Actor[:handler]
|
70
86
|
end
|
71
87
|
|
88
|
+
def initialize_celluloid_logger
|
89
|
+
Celluloid.logger = nil
|
90
|
+
end
|
91
|
+
|
72
92
|
def initialize_thread
|
73
93
|
return unless config.threads == 1
|
74
94
|
handler_class.supervise_as :handler
|
data/lib/servitude/version.rb
CHANGED