Skip to content

Commit

Permalink
Fix puma-wild handling a restart properly. Fixes puma#550
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Oct 30, 2014
1 parent 1c28a30 commit e44ced1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
16 changes: 15 additions & 1 deletion bin/puma-wild
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions lib/puma/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -431,6 +435,7 @@ def restart!
Dir.chdir @restart_dir

argv += [redirects] unless RUBY_VERSION < '1.9'

Kernel.exec(*argv)
end
end
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e44ced1

Please sign in to comment.