Skip to content

Commit e44ced1

Browse files
committed
Fix puma-wild handling a restart properly. Fixes puma#550
1 parent 1c28a30 commit e44ced1

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

bin/puma-wild

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@
55

66
require 'rubygems'
77

8-
deps = ARGV.shift.split(",").each do |s|
8+
gems = ARGV.shift
9+
10+
inc = ""
11+
12+
if gems == "-I"
13+
inc = ARGV.shift
14+
$LOAD_PATH.concat inc.split(":")
15+
gems = ARGV.shift
16+
end
17+
18+
gems.split(",").each do |s|
919
name, ver = s.split(":",2)
1020
gem name, ver
1121
end
1222

23+
module Puma; end
24+
25+
Puma.const_set("WILD_ARGS", ["-I", inc, gems])
26+
1327
require 'puma/cli'
1428

1529
cli = Puma::CLI.new ARGV

lib/puma/cli.rb

+9-3
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,11 @@ def generate_restart_data
363363
lib = File.expand_path "lib"
364364
arg0[1,0] = ["-I", lib] if $:[0] == lib
365365

366-
@restart_argv = arg0 + ARGV
366+
if defined? Puma::WILD_ARGS
367+
@restart_argv = arg0 + Puma::WILD_ARGS + ARGV
368+
else
369+
@restart_argv = arg0 + ARGV
370+
end
367371
end
368372
end
369373

@@ -431,6 +435,7 @@ def restart!
431435
Dir.chdir @restart_dir
432436

433437
argv += [redirects] unless RUBY_VERSION < '1.9'
438+
434439
Kernel.exec(*argv)
435440
end
436441
end
@@ -467,8 +472,9 @@ def run
467472

468473
wild = File.expand_path(File.join(puma_lib_dir, "../bin/puma-wild"))
469474

470-
args = [Gem.ruby] + dirs.map { |x| ["-I", x] }.flatten +
471-
[wild, deps] + @original_argv
475+
wild_loadpath = dirs.join(":")
476+
477+
args = [Gem.ruby] + [wild, "-I", wild_loadpath, deps] + @original_argv
472478

473479
Kernel.exec(*args)
474480
end

0 commit comments

Comments
 (0)