class Qs::RestartCmd

Attributes

argv[R]
dir[R]

Public Class Methods

new() click to toggle source
# File lib/qs/process.rb, line 120
def initialize
  require 'rubygems'
  @dir  = get_pwd
  @argv = [Gem.ruby, $0, ARGV.dup].flatten
end

Public Instance Methods

run() click to toggle source
# File lib/qs/process.rb, line 128
def run
  ENV['QS_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/qs/process.rb, line 150
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