flapjack 0.6.27 → 0.6.28

Sign up to get free protection for your applications and to get access to all the features.
data/bin/flapper ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'eventmachine'
4
+ require 'socket'
5
+
6
+ module Flapper
7
+
8
+ def receive_data data
9
+ send_data ">>>you sent: #{data}"
10
+ close_connection if data =~ /quit/i
11
+ end
12
+
13
+ end
14
+
15
+ def local_ip
16
+ # turn off reverse DNS resolution temporarily
17
+ orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
18
+
19
+ UDPSocket.open do |s|
20
+ s.connect '64.233.187.99', 1
21
+ s.addr.last
22
+ end
23
+ ensure
24
+ Socket.do_not_reverse_lookup = orig
25
+ end
26
+
27
+ start_every = 120
28
+ stop_after = 60
29
+ bind_ip = local_ip
30
+ bind_port = 12345
31
+ EM.run {
32
+
33
+ puts "#{Time.now}: starting server"
34
+ server_init = EM.start_server bind_ip, bind_port, Flapper
35
+ EM.add_timer(stop_after) do
36
+ puts "#{Time.now}: stopping server"
37
+ EM.stop_server(server_init)
38
+ end
39
+
40
+ EM.add_periodic_timer(start_every) do
41
+ puts "#{Time.now}: starting server"
42
+ server = EM.start_server bind_ip, bind_port, Flapper
43
+ EM.add_timer(stop_after) do
44
+ puts "#{Time.now}: stopping server"
45
+ EM.stop_server(server)
46
+ end
47
+ end
48
+ }
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'daemons'
4
+ opts = {
5
+ :app_name => 'flapper',
6
+ :dir_mode => :normal,
7
+ :dir => '/var/run/flapjack',
8
+ :multiple => false,
9
+ :backtrace => true,
10
+ :monitor => false,
11
+ :log_dir => '/var/log/flapjack',
12
+ :log_output => true,
13
+ }
14
+ Daemons.run(File.join(File.dirname(__FILE__) ,'flapper'), opts)
15
+
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.6.27"
4
+ VERSION = "0.6.28"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.27
4
+ version: 0.6.28
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -343,6 +343,8 @@ executables:
343
343
  - flapjack-nagios-receiver-control
344
344
  - flapjack-netsaint-parser
345
345
  - flapjack-populator
346
+ - flapper
347
+ - flapper-control
346
348
  - install-flapjack-systemwide
347
349
  extensions: []
348
350
  extra_rdoc_files: []
@@ -360,6 +362,8 @@ files:
360
362
  - bin/flapjack-nagios-receiver-control
361
363
  - bin/flapjack-netsaint-parser
362
364
  - bin/flapjack-populator
365
+ - bin/flapper
366
+ - bin/flapper-control
363
367
  - bin/install-flapjack-systemwide
364
368
  - config.ru
365
369
  - dist/etc/default/flapjack-notifier