opal-up 0.0.7 → 0.0.8

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: 46fd760653d3303f32429a4dfd767c4d93ac56817393785d7da35632ab2d4ad2
4
- data.tar.gz: a809d96c97f31441dd51c8e5c87aeaee47059835718f62de3217b38348d7d111
3
+ metadata.gz: cb3a4f16540780758e686bbd53c9ab5467b85988bd83a990b05ab54b124c2d2d
4
+ data.tar.gz: 292c74cb7b0771cf807af2b1ebc221707f2b92bd28ca2e1271038b242aa94fc5
5
5
  SHA512:
6
- metadata.gz: 6cd09583959a4340bafda2c118a570df793884fc2813e2b93a251f26220e243910263093c3ff24ac8f9dcc337af5cf1c152f5c9a491e58a5dcc32d035ef5c545
7
- data.tar.gz: 7e45708e9f770ea45dd463dd5bf39075d7d241fe73d0ea60d638e6d80369dec4ae16661b9187525b522440133fa0272df62ca1c982bb132737807c9e05dae6f3
6
+ metadata.gz: 4fbbd939aa7c268d503953c9d7b36d92071c23ae498df1c948acb6886007a66eb60218766528fbb6f5fe1016cdd77890a039533c40fbe3baad8594cca77f8e2d
7
+ data.tar.gz: da01a9584cd43ec5d5c2b97cad04c2bf6895ec029e5e34f4614a9381010788009c97f09c5b8e832913befbb6fb2b3b9157f1baeeff280cbd3e527bb61b4450e6
data/ext/up_ext/up_ext.c CHANGED
@@ -26,6 +26,7 @@ static ID at_instance;
26
26
  static ID at_member_id;
27
27
  static ID at_members;
28
28
  static ID at_open;
29
+ static ID at_port;
29
30
  static ID at_protocol;
30
31
  static ID at_secret;
31
32
  static ID at_server;
@@ -629,6 +630,8 @@ static VALUE up_server_init(int argc, VALUE *argv, VALUE self) {
629
630
  s->port = rport;
630
631
  s->logger = rargs[3];
631
632
 
633
+ rb_ivar_set(self, at_port, s->port);
634
+
632
635
  return self;
633
636
  }
634
637
 
@@ -969,6 +972,7 @@ void Init_up_ext(void) {
969
972
  at_member_id = rb_intern("@member_id");
970
973
  at_members = rb_intern("@members");
971
974
  at_open = rb_intern("@open");
975
+ at_port = rb_intern("@port");
972
976
  at_protocol = rb_intern("@protocol");
973
977
  at_secret = rb_intern("@secret");
974
978
  at_server = rb_intern("@server");
@@ -1,6 +1,7 @@
1
1
  # backtick_javascript: true
2
2
  require 'etc'
3
3
  require 'random/formatter'
4
+ require 'socket'
4
5
  require 'up_ext'
5
6
 
6
7
  module Up
@@ -38,8 +39,10 @@ module Up
38
39
 
39
40
  def install_signal_handlers
40
41
  Signal.trap('CHLD') do
41
- warn "\nError: a cluster member died!"
42
- kill_members
42
+ unless members_alive?
43
+ warn "\nError: a cluster worker died!"
44
+ kill_members
45
+ end
43
46
  end
44
47
  Signal.trap('INT') do
45
48
  warn "\nReceived CTRL-C!"
@@ -49,7 +52,7 @@ module Up
49
52
 
50
53
  def kill_members
51
54
  Signal.trap('CHLD', 'IGNORE')
52
- STDERR.print "Stopping workers: "
55
+ STDERR.print "Stopping all workers: "
53
56
  @members.each do |mid|
54
57
  Process.kill('INT', mid) rescue nil
55
58
  STDERR.print '.'
@@ -58,6 +61,15 @@ module Up
58
61
  warn "\nCluster stopped."
59
62
  Signal.trap('CHLD', 'DEFAULT')
60
63
  end
64
+
65
+ def members_alive?
66
+ @workers.times do |i|
67
+ TCPSocket.new('localhost', @port + i + 1).close
68
+ end
69
+ true
70
+ rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL
71
+ false
72
+ end
61
73
  end
62
74
  end
63
75
  end
data/lib/up/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Up
2
- VERSION = '0.0.7'.freeze
2
+ VERSION = '0.0.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann