class Puma::Launcher
def generate_restart_data
def generate_restart_data if dir = @options[:directory] @restart_dir = dir elsif Puma.windows? # I guess the value of PWD is garbage on windows so don't bother # using it. @restart_dir = Dir.pwd # Use the same trick as unicorn, namely favor PWD because # it will contain an unresolved symlink, useful for when # the pwd is /data/releases/current. elsif dir = ENV['PWD'] s_env = File.stat(dir) s_pwd = File.stat(Dir.pwd) if s_env.ino == s_pwd.ino and (Puma.jruby? or s_env.dev == s_pwd.dev) @restart_dir = dir end end @restart_dir ||= Dir.pwd # if $0 is a file in the current directory, then restart # it the same, otherwise add -S on there because it was # picked up in PATH. # if File.exist?($0) arg0 = [Gem.ruby, $0] else arg0 = [Gem.ruby, "-S", $0] end # Detect and reinject -Ilib from the command line, used for testing without bundler # cruby has an expanded path, jruby has just "lib" lib = File.expand_path "lib" arg0[1,0] = ["-I", lib] if [lib, "lib"].include?($LOAD_PATH[0]) if defined? Puma::WILD_ARGS @restart_argv = arg0 + Puma::WILD_ARGS + @original_argv else @restart_argv = arg0 + @original_argv end end