Class: Ramaze::Bin::Restart
Overview
Constant Summary
- Description =
The description of this command, displayed in the global help message.
'Restarts an application'- Banner =
The banner, displayed when the -h or --help option is specified.
"Restarts an active Ramaze application.\n\nUsage:\nramaze restart [RACKUP] [OPTIONS]\n\nExample:\nramaze restart config.ru -P ramaze.pid\n".strip
Instance Method Summary (collapse)
-
- (Restart) initialize
constructor
Creates a new instance of the command and sets all the options.
-
- (Object) run(argv = [])
Runs the command based on the specified command line arguments.
Constructor Details
- (Restart) initialize
Creates a new instance of the command and sets all the options.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ramaze/bin/restart.rb', line 40 def initialize = OptionParser.new do |opt| opt. = Banner opt.summary_indent = ' ' opt.separator "\nOptions:\n" opt.on('-h', '--help', 'Shows this help message') do puts exit end opt.on( '-P', '--pid FILE', 'Uses the PID to kill the application' ) do |pid| @pid = pid end end end |
Instance Method Details
- (Object) run(argv = [])
Runs the command based on the specified command line arguments.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ramaze/bin/restart.rb', line 69 def run(argv = []) .parse!(argv) @rackup = argv.delete_at(0) @rackup = File.join(Dir.pwd, 'config.ru') if @rackup.nil? if File.directory?(@rackup) @rackup = File.join(@rackup, 'config.ru') end if !File.exist?(@rackup) abort "The Rackup file #{@rackup} does not exist" end stop = Ramaze::Bin::Runner::Commands[:stop].new start = Ramaze::Bin::Runner::Commands[:start].new params = [@rackup] unless @pid.nil? params.push("-P #{@pid}") end stop.run([@pid]) start.run(params) end |