fizx-proxymachine 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :build:
3
3
  :major: 1
4
- :minor: 2
4
+ :minor: 3
5
5
  :patch: 0
data/bin/proxymachine CHANGED
@@ -38,8 +38,8 @@ rescue Exception => e
38
38
  if e.instance_of?(SystemExit)
39
39
  raise
40
40
  else
41
- LOGGER.info 'Uncaught exception'
42
- LOGGER.info e.message
43
- LOGGER.info e.backtrace.join("\n")
41
+ $logger.info 'Uncaught exception'
42
+ $logger.info e.message
43
+ $logger.info e.backtrace.join("\n")
44
44
  end
45
45
  end
data/examples/git.rb CHANGED
@@ -6,7 +6,7 @@ class GitRouter
6
6
  # Look at the routing table and return the correct address for +name+
7
7
  # Returns "<host>:<port>" e.g. "ae8f31c.example.com:9418"
8
8
  def self.lookup(name)
9
- LOGGER.info "Proxying for user #{name}"
9
+ $logger.info "Proxying for user #{name}"
10
10
  "localhost:9418"
11
11
  end
12
12
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fizx-proxymachine}
8
- s.version = "1.2.0"
8
+ s.version = "1.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tom Preston-Werner", "Kyle Maxwell"]
12
- s.date = %q{2010-01-10}
12
+ s.date = %q{2010-01-20}
13
13
  s.default_executable = %q{proxymachine}
14
14
  s.email = %q{tom@mojombo.com}
15
15
  s.executables = ["proxymachine"]
data/lib/proxymachine.rb CHANGED
@@ -7,7 +7,7 @@ require 'proxymachine/client_connection'
7
7
  require 'proxymachine/server_connection'
8
8
  require 'proxymachine/callback_server_connection'
9
9
 
10
- LOGGER = Logger.new(STDOUT)
10
+ $logger = Logger.new(STDOUT)
11
11
 
12
12
  class ProxyMachine
13
13
  MAX_FAST_SHUTDOWN_SECONDS = 10
@@ -35,7 +35,7 @@ class ProxyMachine
35
35
  def self.decr
36
36
  @@counter -= 1
37
37
  if $server.nil?
38
- LOGGER.info "Waiting for #{@@counter} connections to finish."
38
+ $logger.info "Waiting for #{@@counter} connections to finish."
39
39
  end
40
40
  self.update_procline
41
41
  EM.stop if $server.nil? and @@counter == 0
@@ -52,17 +52,17 @@ class ProxyMachine
52
52
 
53
53
  def self.graceful_shutdown(signal)
54
54
  EM.stop_server($server) if $server
55
- LOGGER.info "Received #{signal} signal. No longer accepting new connections."
56
- LOGGER.info "Waiting for #{ProxyMachine.count} connections to finish."
55
+ $logger.info "Received #{signal} signal. No longer accepting new connections."
56
+ $logger.info "Waiting for #{ProxyMachine.count} connections to finish."
57
57
  $server = nil
58
58
  EM.stop if ProxyMachine.count == 0
59
59
  end
60
60
 
61
61
  def self.fast_shutdown(signal)
62
62
  EM.stop_server($server) if $server
63
- LOGGER.info "Received #{signal} signal. No longer accepting new connections."
64
- LOGGER.info "Maximum time to wait for connections is #{MAX_FAST_SHUTDOWN_SECONDS} seconds."
65
- LOGGER.info "Waiting for #{ProxyMachine.count} connections to finish."
63
+ $logger.info "Received #{signal} signal. No longer accepting new connections."
64
+ $logger.info "Maximum time to wait for connections is #{MAX_FAST_SHUTDOWN_SECONDS} seconds."
65
+ $logger.info "Waiting for #{ProxyMachine.count} connections to finish."
66
66
  $server = nil
67
67
  EM.stop if ProxyMachine.count == 0
68
68
  Thread.new do
@@ -17,7 +17,7 @@ class ProxyMachine
17
17
  @client_side.send_data returned
18
18
  end
19
19
  rescue => e
20
- LOGGER.info e.message + e.backtrace.join("\n")
20
+ $logger.info e.message + e.backtrace.join("\n")
21
21
  end
22
22
 
23
23
  def unbind
@@ -2,13 +2,13 @@ class ProxyMachine
2
2
  class ClientConnection < EventMachine::Connection
3
3
  def self.start(host, port)
4
4
  $server = EM.start_server(host, port, self)
5
- LOGGER.info "Listening on #{host}:#{port}"
6
- LOGGER.info "Send QUIT to quit after waiting for all connections to finish."
7
- LOGGER.info "Send TERM or INT to quit after waiting for up to 10 seconds for connections to finish."
5
+ $logger.info "Listening on #{host}:#{port}"
6
+ $logger.info "Send QUIT to quit after waiting for all connections to finish."
7
+ $logger.info "Send TERM or INT to quit after waiting for up to 10 seconds for connections to finish."
8
8
  end
9
9
 
10
10
  def post_init
11
- LOGGER.info "Accepted #{peer}"
11
+ $logger.info "Accepted #{peer}"
12
12
  @buffer = []
13
13
  @tries = 0
14
14
  ProxyMachine.incr
@@ -29,14 +29,14 @@ class ProxyMachine
29
29
  end
30
30
  rescue => e
31
31
  close_connection
32
- LOGGER.info "#{e.class} - #{e.message}"
32
+ $logger.info "#{e.class} - #{e.message}"
33
33
  end
34
34
 
35
35
  def ensure_server_side_connection
36
36
  @timer.cancel if @timer
37
37
  unless @server_side
38
38
  commands = ProxyMachine.router.call(@buffer.join)
39
- LOGGER.info "#{peer} #{commands.inspect}"
39
+ $logger.info "#{peer} #{commands.inspect}"
40
40
  close_connection unless commands.instance_of?(Hash)
41
41
  if remote = commands[:remote]
42
42
  m, host, port = *remote.match(/^(.+):(.+)$/)
@@ -70,18 +70,18 @@ class ProxyMachine
70
70
  def try_server_connect(host, port, klass)
71
71
  @server_side = klass.request(host, port, self)
72
72
  proxy_incoming_to(@server_side, 10240)
73
- LOGGER.info "Successful connection to #{host}:#{port}."
73
+ $logger.info "Successful connection to #{host}:#{port}."
74
74
  true
75
75
  rescue => e
76
76
  if @tries < 10
77
77
  @tries += 1
78
- LOGGER.info "Failed on server connect attempt #{@tries}. Trying again..."
78
+ $logger.info "Failed on server connect attempt #{@tries}. Trying again..."
79
79
  @timer.cancel if @timer
80
80
  @timer = EventMachine::Timer.new(0.1) do
81
81
  self.ensure_server_side_connection
82
82
  end
83
83
  else
84
- LOGGER.info "Failed after ten connection attempts."
84
+ $logger.info "Failed after ten connection attempts."
85
85
  end
86
86
  false
87
87
  end
@@ -1,4 +1,4 @@
1
- LOGGER = Logger.new(File.new('/dev/null', 'w'))
1
+ $logger = Logger.new(File.new('/dev/null', 'w'))
2
2
 
3
3
  callback = proc do |data|
4
4
  data + ":callback"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fizx-proxymachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-10 00:00:00 -08:00
13
+ date: 2010-01-20 00:00:00 -08:00
14
14
  default_executable: proxymachine
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency