-
-
Save nateberkopec/386db42c0eb3fe4fa91b009dd9f1f84b to your computer and use it in GitHub Desktop.
diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index 8d3f5b5..8aa012f 100644 | |
--- a/lib/puma/launcher.rb | |
+++ b/lib/puma/launcher.rb | |
@@ -258,19 +258,17 @@ module Puma | |
end | |
def prune_bundler | |
- return unless defined?(Bundler) | |
- puma = Bundler.rubygems.loaded_specs("puma") | |
- dirs = puma.require_paths.map { |x| File.join(puma.full_gem_path, x) } | |
+ puma = spec_for_gem("puma") | |
+ dirs = puma.full_require_paths | |
puma_lib_dir = dirs.detect { |x| File.exist? File.join(x, '../bin/puma-wild') } | |
- unless puma_lib_dir | |
+ unless puma_lib_dir && defined?(Bundler) | |
log "! Unable to prune Bundler environment, continuing" | |
return | |
end | |
deps = puma.runtime_dependencies.map do |d| | |
- spec = Bundler.rubygems.loaded_specs(d.name) | |
- "#{d.name}:#{spec.version.to_s}" | |
+ "#{d.name}:#{spec_for_gem(d.name).version}" | |
end | |
log '* Pruning Bundler environment' | |
@@ -280,11 +278,18 @@ module Puma | |
ENV['PUMA_BUNDLER_PRUNED'] = '1' | |
wild = File.expand_path(File.join(puma_lib_dir, "../bin/puma-wild")) | |
args = [Gem.ruby, wild, '-I', dirs.join(':'), deps.join(',')] + @original_argv | |
- # Ruby 2.0+ defaults to true which breaks socket activation | |
- args += [{:close_others => false}] if RUBY_VERSION >= '2.0' | |
+ args += [{:close_others => false}] | |
Kernel.exec(*args) | |
end | |
end | |
+ | |
+ def spec_for_gem(gem_name) | |
+ Bundler.rubygems.loaded_specs(gem_name) | |
+ end | |
+ | |
+ def require_paths_for_gem(gem_spec) | |
+ gem_spec.full_require_paths | |
+ end | |
def log(str) | |
@events.log str |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment