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 +4 -4
- data/CHANGELOG.md +6 -0
- data/bin/start_puma.rb +6 -10
- data/example/puma/config/puma.conf.rb +8 -7
- data/lib/server/starter/puma_listener.rb +11 -1
- data/lib/server/starter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 172f969ecca0954a1b3f5a44df94ad9e391893cf
|
4
|
+
data.tar.gz: 414f7dc2679b28e65d4d8ebc289032540476d83f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5e0704849bf69e29e582cea3681bdf3f5578ead49cea74f87cb919ecbafafe975dd537f6e60dfdb42378dc124f98a14c0d8eb46bf76b32793d7b4628621dae8
|
7
|
+
data.tar.gz: d2f77e9459789f62758b8f0a24bd090a295646e5e4b3d681e9cec992824234a661cf7f10737b8cad5810c7d1cf99de5ab3ee4dcaed56b09354912d91b59c3d82
|
data/CHANGELOG.md
CHANGED
data/bin/start_puma.rb
CHANGED
@@ -1,15 +1,11 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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['
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
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
|
-
|
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
|