Sha256: 44d2328fa2a5d606d3c0a581ee9b5ff0923fedb81a939869e116fab0b8a087d1

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module Brindle
  
  class Restart < GemPlugin::Plugin "/commands"
    include GoldenBrindle::Command::Base
    
    def configure 
      options [ 
        ['-c', '--chdir PATH', "Change to dir before starting (will be expanded).", :@cwd, "."],
        ['-C', '--config PATH', "Use a mongrel based config file", :@config_file, nil],
        ['-s', '--soft', "Do a soft restart rather than a process exit restart", :@soft, false],
        ['-P', '--pid FILE', "Where the PID file is located.", :@pid_file, "tmp/pids/unicorn.pid"]
      ]
    end

    def validate
      if @config_file
        valid_exists?(@config_file, "Config file not there: #@config_file")
        return false unless @valid
        @config_file = File.expand_path(@config_file)
        load_config
        return false unless @valid
      end
      
      @cwd = File.expand_path(@cwd)
      valid_dir? @cwd, "Invalid path to change to during daemon mode: #@cwd"
      return false unless @valid
      Dir.chdir @cwd

      valid_exists? @pid_file, "PID file #@pid_file does not exist.  Not running?"
      return @valid
    end

    def run
      if @soft
        GoldenBrindle::send_signal("HUP", @pid_file)
      else
        GoldenBrindle::send_signal("USR2", @pid_file)
      end
    end
    
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
golden_brindle-0.0.3 lib/golden_brindle/restart.rb
golden_brindle-0.0.2 lib/golden_brindle/restart.rb
golden_brindle-0.0.1 lib/golden_brindle/restart.rb