protobuf 2.5.5-java → 2.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,13 +16,14 @@ module Protobuf
16
16
  @broker = ::Protobuf::Rpc::Zmq::Broker.new(options)
17
17
  local_worker_threads = options[:threads]
18
18
 
19
- worker_options = options.merge(:port => options[:port] + 1)
19
+ @worker_options = options.merge(:port => options[:port] + 1)
20
20
  log_debug { sign_message("starting server workers") }
21
+
21
22
  local_worker_threads.times do
22
- @threads << Thread.new { ::Protobuf::Rpc::Zmq::Worker.new(worker_options).run }
23
+ self.start_worker
23
24
  end
24
- @running = true
25
25
 
26
+ @running = true
26
27
  log_debug { sign_message("server started") }
27
28
  while self.running? do
28
29
  @broker.poll
@@ -35,6 +36,21 @@ module Protobuf
35
36
  !!@running
36
37
  end
37
38
 
39
+ def self.start_worker(failed_worker = false)
40
+ @threads.select! { |t| t.alive? } if failed_worker
41
+
42
+ @threads << Thread.new(self, @worker_options) { |parent_server, worker_options|
43
+ begin
44
+ ::Protobuf::Rpc::Zmq::Worker.new(worker_options).run
45
+ rescue => e
46
+ if parent_server.running?
47
+ log_error { parent_server.sign_message("Restart Worker on Exception: #{e.inspect}\n #{e.backtrace}") }
48
+ parent_server.start_worker(true)
49
+ end
50
+ end
51
+ }
52
+ end
53
+
38
54
  def self.stop
39
55
  @running = false
40
56
 
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.5.5'
2
+ VERSION = '2.6.0'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.5.5
5
+ version: 2.6.0
6
6
  platform: java
7
7
  authors:
8
8
  - BJ Neilsen
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-12-19 00:00:00 Z
14
+ date: 2013-01-02 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport