diff --git a/bin/puma-wild b/bin/puma-wild index b54fc57f..b3ba0152 100644 --- a/bin/puma-wild +++ b/bin/puma-wild @@ -5,11 +5,25 @@ require 'rubygems' -deps = ARGV.shift.split(",").each do |s| +gems = ARGV.shift + +inc = "" + +if gems == "-I" + inc = ARGV.shift + $LOAD_PATH.concat inc.split(":") + gems = ARGV.shift +end + +gems.split(",").each do |s| name, ver = s.split(":",2) gem name, ver end +module Puma; end + +Puma.const_set("WILD_ARGS", ["-I", inc, gems]) + require 'puma/cli' cli = Puma::CLI.new ARGV diff --git a/lib/puma/cli.rb b/lib/puma/cli.rb index 29b84ac6..b2a75952 100644 --- a/lib/puma/cli.rb +++ b/lib/puma/cli.rb @@ -363,7 +363,11 @@ module Puma lib = File.expand_path "lib" arg0[1,0] = ["-I", lib] if $:[0] == lib - @restart_argv = arg0 + ARGV + if defined? Puma::WILD_ARGS + @restart_argv = arg0 + Puma::WILD_ARGS + ARGV + else + @restart_argv = arg0 + ARGV + end end end @@ -431,6 +435,7 @@ module Puma Dir.chdir @restart_dir argv += [redirects] unless RUBY_VERSION < '1.9' + Kernel.exec(*argv) end end @@ -467,8 +472,9 @@ module Puma wild = File.expand_path(File.join(puma_lib_dir, "../bin/puma-wild")) - args = [Gem.ruby] + dirs.map { |x| ["-I", x] }.flatten + - [wild, deps] + @original_argv + wild_loadpath = dirs.join(":") + + args = [Gem.ruby] + [wild, "-I", wild_loadpath, deps] + @original_argv Kernel.exec(*args) end