Restarts an application based on a specified directory/rackup file and PID. The PID is used to kill the process, the Rackup file is used to start the process again after it has been killed.
Usage:
ramaze restart ramaze restart /home/foobar/projects/ramaze/ \ -P /home/foobar/projects/ramaze/ramaze.pid
@author Yorick Peterse @since 21-07-2011
The description of this command, displayed in the global help message.
The banner, displayed when the -h or —help option is specified.
Creates a new instance of the command and sets all the options.
@author Yorick Peterse @since 21-07-2011
# File lib/ramaze/bin/restart.rb, line 39 39: def initialize 40: @options = OptionParser.new do |opt| 41: opt.banner = Banner 42: opt.summary_indent = ' ' 43: 44: opt.separator "\nOptions:\n" 45: 46: opt.on('-h', '--help', 'Shows this help message') do 47: puts @options 48: exit 49: end 50: 51: opt.on( 52: '-P', 53: '--pid FILE', 54: 'Uses the PID to kill the application' 55: ) do |pid| 56: @pid = pid 57: end 58: end 59: end
Runs the command based on the specified command line arguments.
@author Yorick Peterse @since 21-07-2011 @param [Array] argv An array containing all command line arguments.
# File lib/ramaze/bin/restart.rb, line 68 68: def run(argv = []) 69: @options.parse!(argv) 70: 71: @rackup = argv.delete_at(0) 72: @rackup = File.join(Dir.pwd, 'config.ru') if @rackup.nil? 73: 74: if File.directory?(@rackup) 75: @rackup = File.join(@rackup, 'config.ru') 76: end 77: 78: if !File.exist?(@rackup) 79: abort "The Rackup file #{@rackup} does not exist" 80: end 81: 82: stop = Ramaze::Bin::Runner::Commands[:stop].new 83: start = Ramaze::Bin::Runner::Commands[:start].new 84: params = [@rackup] 85: 86: unless @pid.nil? 87: params.push("-P #{@pid}") 88: end 89: 90: stop.run([@pid]) 91: start.run(params) 92: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.