envoy-proxy 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: d9e12a9dc7bdb8e9ed83fd43ed0721c7c24fe93c
4
- data.tar.gz: 960a0a5cb549bb9bd9c5800bdf241cb3d1c75006
3
+ metadata.gz: b37ea6c959f8c114427789454f1b57839190d78f
4
+ data.tar.gz: 5160742eaafd4c19c7dc7d5dae52ea9f778840f1
5
5
  SHA512:
6
- metadata.gz: 8cc30bd5f5b6b967bef9ee9ee97635a94c489c48c3cc82642e0d8f00da73890bfb7c67ae2f1605975647c9029aab459dbaa8494b3b84dec7990249ecbd9be579
7
- data.tar.gz: aafbf07d55daea5fdb3eb0e0ee98037c204e6f65f53c89ce3dbebc16ac42fc217f9ec1e7e00d4d38053881d8617b04f213f57e2b4bdc0ddf54d9b85a3d0082b6
6
+ metadata.gz: 7278fc984cc99dfb7761bcaf94a2a2fcef994e468ba46ea53a36976b43c5a2a57c3ad74da662cd2b0e03bf019c5dfed11f149d24e5eb19dc43056916ec9140d0
7
+ data.tar.gz: fa1f633ac93d12a3a72fe71f21ef9767f80aef9677f263ce839fd24da2030c0b13fdb567a5af8add464566484a424635992f81212590a226315357149af6b24b
data/README.md CHANGED
@@ -42,7 +42,7 @@ connection is refused.
42
42
 
43
43
  Option Description Default
44
44
  ---------------------------------------------------------------------------
45
- host The domain name prefix None
45
+ host The domain name prefix Last component of dir, or None
46
46
  local_port The local port to use None
47
47
  local_host The local host to use 127.0.0.1
48
48
  server_host The server host to use p45.eu
@@ -50,11 +50,15 @@ connection is refused.
50
50
  tls Use TLS in the server connections false
51
51
  verbose Be noisy false
52
52
  command A command to run if a local connection is refused None
53
- delay Number of seconds to wait before reconnecting, 1
54
- after starting a command
53
+ delay Number of seconds to wait for a command to start 1
55
54
  dir A directory to change to None
55
+ rails A directory to change to; contains a Rails app None
56
+ rackup A directory to change to; contains a Rack app None
56
57
  log A file to log to /dev/stderr
57
58
 
59
+ The `rails` and `rackup` options specify `dir` and `command` options for Rails
60
+ and Rack applications, respectively.
61
+
58
62
  If no host is specified, a random one is selected by the server.
59
63
  If no local port is specified, a random one is selected by the client.
60
64
  The command is processed for % substitions against the configuration hash,
@@ -12,6 +12,7 @@ module Envoy
12
12
  end
13
13
 
14
14
  def connection_completed
15
+ @tried_starting = nil
15
16
  send_data @buffer, true
16
17
  @buffer = nil
17
18
  end
@@ -35,15 +36,22 @@ module Envoy
35
36
  def unbind e
36
37
  if e == Errno::ECONNREFUSED
37
38
  if @tried_starting
38
- @client.log "Service isn't running, but starting it didn't really work out."
39
- @client.send_object :close, @id, 502
39
+ if Time.now > @tried_starting + @client.options[:delay]
40
+ @client.log "Service isn't running, but starting it didn't really work out."
41
+ @client.send_object :close, @id, 502
42
+ @tried_starting = false
43
+ else
44
+ EM.add_timer 0.1 do
45
+ reconnect
46
+ end
47
+ end
40
48
  elsif cmd = @client.options[:command]
41
49
  cmd = cmd % @client.options
42
50
  @client.log "Service doesn't seem to be running. Trying to start it now..."
43
- @tried_starting = true
51
+ @tried_starting = Time.now
52
+ p @client.options[:dir]
44
53
  Dir.chdir File.expand_path(@client.options[:dir]) do
45
54
  fork do
46
- #Process.daemon(true, false)
47
55
  ENV.delete("GEM_HOME")
48
56
  ENV.delete("GEM_PATH")
49
57
  ENV.delete("BUNDLE_BIN_PATH")
@@ -51,7 +59,7 @@ module Envoy
51
59
  system cmd
52
60
  end
53
61
  end
54
- EM.add_timer @client.options[:delay] do
62
+ EM.add_timer 0.1 do
55
63
  reconnect
56
64
  end
57
65
  end
@@ -18,7 +18,20 @@ end
18
18
  def load_config
19
19
  if path = find_config
20
20
  conf = YAML.load(File.read(path))
21
- conf.is_a?(Array) ? conf : [conf]
21
+ Array(conf).each do |conf|
22
+ if conf["rails"]
23
+ conf["dir"] = conf["rails"]
24
+ conf["pidfile"] = "tmp/pids/server.pid"
25
+ conf["command"] = "rails s -p %{local_port}"
26
+ conf["delay"] = 10
27
+ elsif conf["rackup"]
28
+ conf["dir"] = conf["rackup"]
29
+ conf["command"] = "rackup -p %{local_port}"
30
+ conf["delay"] = 10
31
+ end
32
+ conf["host"] ||= conf["dir"].split("/")[-1] if conf["dir"]
33
+ conf["dir"] = File.expand_path(conf["dir"], path + "/..") if conf["dir"]
34
+ end
22
35
  else
23
36
  [{"local_port" => "80"}]
24
37
  end
@@ -1,3 +1,3 @@
1
1
  module Envoy
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envoy-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Baum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2013-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine