def restart!
@options[:on_restart].each do |block|
block.call self
end
if jruby?
@binder.listeners.each_with_index do |(str,io),i|
io.close
uri = URI.parse str
if uri.scheme == "unix"
path = "#{uri.host}#{uri.path}"
File.unlink path
end
end
require 'puma/jruby_restart'
JRubyRestart.chdir_exec(@restart_dir, restart_args)
elsif windows?
@binder.listeners.each_with_index do |(str,io),i|
io.close
uri = URI.parse str
if uri.scheme == "unix"
path = "#{uri.host}#{uri.path}"
File.unlink path
end
end
argv = restart_args
Dir.chdir @restart_dir
argv += [redirects] unless RUBY_VERSION < '1.9'
Kernel.exec(*argv)
else
redirects = {:close_others => true}
@binder.listeners.each_with_index do |(l,io),i|
ENV["PUMA_INHERIT_#{i}"] = "#{io.to_i}:#{l}"
redirects[io.to_i] = io.to_i
end
argv = restart_args
Dir.chdir @restart_dir
argv += [redirects] unless RUBY_VERSION < '1.9'
Kernel.exec(*argv)
end
end