From e44ced1d1f7ad7b604a43fa38bea150403c5cf64 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Wed, 29 Oct 2014 17:07:25 -0700 Subject: [PATCH] Fix puma-wild handling a restart properly. Fixes #550 --- bin/puma-wild | 16 +++++++++++++++- lib/puma/cli.rb | 12 +++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/bin/puma-wild b/bin/puma-wild index b54fc57f6a..b3ba0152e3 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 29b84ac66a..b2a75952a6 100644 --- a/lib/puma/cli.rb +++ b/lib/puma/cli.rb @@ -363,7 +363,11 @@ def generate_restart_data 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 @@ def restart! Dir.chdir @restart_dir argv += [redirects] unless RUBY_VERSION < '1.9' + Kernel.exec(*argv) end end @@ -467,8 +472,9 @@ def run 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