server-starter 0.2.0 → 0.2.1

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: c8b2e1016a56a58b14b4aeaaa37823b343816a5f
4
- data.tar.gz: 85ec3da094558506221d980a185f7a2dcb8e79f9
3
+ metadata.gz: 172f969ecca0954a1b3f5a44df94ad9e391893cf
4
+ data.tar.gz: 414f7dc2679b28e65d4d8ebc289032540476d83f
5
5
  SHA512:
6
- metadata.gz: 671005c01b169fa2c415f93ccd12817b80ccd938aca82355313f74465419d93d188624353a0d94be77dc30a9b6f4bef397364b6c64fc2b80fa854b45d3eac886
7
- data.tar.gz: 74d3bcc535fa7d3613f9e68369d467603b85640269eee77821baa3ca6c85ef6a186e6d871cd3f14b672407b4095e2fc8d5c46b25df671efad89a8f141a5f963d
6
+ metadata.gz: f5e0704849bf69e29e582cea3681bdf3f5578ead49cea74f87cb919ecbafafe975dd537f6e60dfdb42378dc124f98a14c0d8eb46bf76b32793d7b4628621dae8
7
+ data.tar.gz: d2f77e9459789f62758b8f0a24bd090a295646e5e4b3d681e9cec992824234a661cf7f10737b8cad5810c7d1cf99de5ab3ee4dcaed56b09354912d91b59c3d82
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.1 (2016/04/03)
2
+
3
+ Fixes:
4
+
5
+ * Fix to support puma
6
+
1
7
  ## 0.2.0 (2016/04/03)
2
8
 
3
9
  Enhancements:
data/bin/start_puma.rb CHANGED
@@ -1,15 +1,11 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- if ENV.key?('SERVER_STARTER_PORT')
4
- ENV['SERVER_STARTER_PORT'].split(';').each.with_index do |x, i|
5
- path_or_port, fd = x.split('=', 2)
6
- if path_or_port.match(/(?:^|:)\d+$/)
7
- url = "tcp://#{path_or_port}"
8
- else
9
- url = "unix://#{path_or_port}"
10
- end
11
- ENV["PUMA_INHERIT_#{i}"] = "#{fd}:#{url}"
12
- end
3
+ require 'server/starter/puma_listener'
4
+ listener = ::Server::Starter::PumaListener
5
+
6
+ unless listener.listen # Configure PUMA_INHERIT_\d NEV
7
+ $stderr.puts "[ERROR] Not running under server starter"
8
+ exit 1
13
9
  end
14
10
 
15
11
  args = ARGV.dup
@@ -1,3 +1,6 @@
1
+ require 'server/starter/puma_listener'
2
+ listener = ::Server::Starter::PumaListener
3
+
1
4
  APP_ROOT = File.expand_path('../..', __FILE__)
2
5
  status_file = File.join(APP_ROOT, 'log/start_server.stat')
3
6
 
@@ -17,15 +20,13 @@ workers 2
17
20
 
18
21
  # Run puma via start_puma.rb to configure PUMA_INHERIT_\d ENV from SERVER_STARTER_PORT ENV as
19
22
  # $ bundle exec --keep-file-descriptors start_puma.rb puma -C config/puma.conf.rb config.ru
20
- if ENV['PUMA_INHERIT_0']
21
- ENV.each do |k,v|
22
- if k =~ /PUMA_INHERIT_\d+/
23
- fd, url = v.split(":", 2)
24
- bind url
25
- end
23
+ if ENV['SERVER_STARTER_PORT']
24
+ puma_inherits = listener.listen
25
+ puma_inherits.each do |puma_inherit|
26
+ bind puma_inherit[:url]
26
27
  end
27
28
  else
28
- # Fallback if not running under Server::Starter
29
+ puts '[WARN] Fallback to 0.0.0.0:10080 since not running under Server::Starter'
29
30
  bind 'tcp://0.0.0.0:10080'
30
31
  end
31
32
 
@@ -3,7 +3,17 @@ require 'server/starter/version'
3
3
  class Server::Starter
4
4
  class PumaListener
5
5
  def self.listen
6
- $stderr.puts "Configure ENV in config seems too late. Use start_puma.rb instead"
6
+ return nil unless ENV.key?('SERVER_STARTER_PORT')
7
+ ENV['SERVER_STARTER_PORT'].split(';').map.with_index do |x, i|
8
+ path_or_port, fd = x.split('=', 2)
9
+ if path_or_port.match(/(?:^|:)\d+$/)
10
+ url = "tcp://#{path_or_port}"
11
+ else
12
+ url = "unix://#{path_or_port}"
13
+ end
14
+ ENV["PUMA_INHERIT_#{i}"] = "#{fd}:#{url}"
15
+ { fd: fd, url: url }
16
+ end
7
17
  end
8
18
  end
9
19
  end
@@ -1,5 +1,5 @@
1
1
  class Server
2
2
  class Starter
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: server-starter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo