class Sanford::RestartCmd
Attributes
argv[R]
dir[R]
Public Class Methods
new()
click to toggle source
# File lib/sanford/process.rb, line 134 def initialize require 'rubygems' @dir = get_pwd @argv = [Gem.ruby, $0, ARGV.dup].flatten end
Public Instance Methods
run(server)
click to toggle source
# File lib/sanford/process.rb, line 142 def run(server) ENV['SANFORD_SERVER_FD'] = server.file_descriptor.to_s ENV['SANFORD_CLIENT_FDS'] = server.client_file_descriptors.join(',') ENV['SANFORD_SKIP_DAEMONIZE'] = 'yes' Dir.chdir self.dir Kernel.exec(*self.argv) end
Private Instance Methods
get_pwd()
click to toggle source
Trick from puma/unicorn. Favor PWD because it contains an unresolved symlink. This is useful when restarting after deploying; the original directory may be removed, but the symlink is pointing to a new directory.
# File lib/sanford/process.rb, line 178 def get_pwd return Dir.pwd if ENV['PWD'].nil? env_stat = File.stat(ENV['PWD']) pwd_stat = File.stat(Dir.pwd) if env_stat.ino == pwd_stat.ino && env_stat.dev == pwd_stat.dev ENV['PWD'] else Dir.pwd end end