Sha256: e98b0a3050cf31d061ed07f5390b6e8c1e25e097525bdf44ca8ca8ff6e6bbf4f
Contents?: true
Size: 1.45 KB
Versions: 3
Compression:
Stored size: 1.45 KB
Contents
module Brindle class Stop < 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], ['-f', '--force', "Force the shutdown (kill -9).", :@force, false], ['-w', '--wait SECONDS', "Wait SECONDS before forcing shutdown", :@wait, "0"], ['-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 @force @wait.to_i.times do |waiting| exit(0) if not File.exist? @pid_file sleep 1 end GoldenBrindle::send_signal("KILL", @pid_file) if File.exist? @pid_file else GoldenBrindle::send_signal("TERM", @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/stop.rb |
golden_brindle-0.0.2 | lib/golden_brindle/stop.rb |
golden_brindle-0.0.1 | lib/golden_brindle/stop.rb |