Method: Nitro::Runner#setup_options
- Defined in:
- lib/nitro/server/runner.rb
#setup_options ⇒ Object
Parse the command line arguments and the environment parameters to setup the application.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/nitro/server/runner.rb', line 50 def @action ||= :start @daemon = false @spider = false # Setup from command line arguments. parser = OptionParser.new do |opts| opts. = 'Usage: run.rb [options]' opts.separator '' opts.separator 'Specific options:' opts.on('-s', '--start', 'Start application.') do @action = :start end opts.on('-S', '--stop', 'Stop application.') do @action = :stop end opts.on('-r', '--restart', 'Restart application.') do @action = :restart end opts.on('-d', '--daemon', 'Run application as a daemon.') do @daemon = true end opts.on('-D', '--debug', 'Run application in debug mode.') do Configuration.mode = :debug end opts.on('-T', '--stage', 'Run application in stage mode.') do Configuration.mode = :stage end opts.on('-L', '--live', 'Run application in live mode.') do Configuration.mode = :live end opts.on('--address IP', 'Force the server to run on this address.') do |a| @server_address = a end opts.on('--port PORT', 'Force the server to run on this port.') do |p| @server_port = p.to_i end opts.on('--port_offset PORT', 'The port offset in the cluster.') do |o| @server_port_offset = o.to_i end opts.on('-w', '--webrick', 'Use a webrick server [default].') do Nitro.adapter = :webrick end opts.on('-m', '--mongrel', 'Use the Mongrel Ruby server.') do Nitro.adapter = :mongrel # FIXME: handle logging. end opts.on('-l', '--lhttpd', 'Use a lighttpd server (FastCGI).') do Nitro.adapter = :lhttpd Logger.set(Logger.new('log/app.log')) end opts.on('-l', '--lhttpd-scgi', 'Use the SCGI adapter (Lighttpd).') do Nitro.adapter = :lhttpd_scgi Logger.set(Logger.new('log/app.log')) end opts.on('-a', '--apache', 'Use an apache server.') do Nitro.adapter = :apache Logger.set(Logger.new('log/app.log')) end opts.on('--apache-cgi', 'Use the CGI adapter (Apache)') do Nitro.adapter = :cgi Logger.set(Logger.new('log/app.log')) end opts.on('--scgi', 'Use the generic SCGI adapter') do Nitro.adapter = :scgi end opts.on('--crawl', 'Crawl the application.') do Nitro.adapter = :webrick @spider = :crawl end opts.on('--render', 'Crawl the application and render all pages as static html files.') do Nitro.adapter = :webrick @spider = :render end opts.on_tail('-h', '--help', 'Show this message.') do puts opts exit end # Hack fix for bin/nitro. opts.on_tail('-v', '--verbose', 'Verbose mode') do # nop, hack fix. end opts.on('--destroy') do # nop, hack fix. end opts.on('-C', '--console', 'Start a console attached to an instance of the application.') do # nop, hack fix. end opts.on('--app', 'The application name') do |adapter| # nop, hack fix. end opts.on('--mode', 'Set the execution mode') do |adapter| # nop, hack fix. end opts.on('--adapter', 'Set the adapter to use') do |adapter| # nop, hack fix. end opts.on('--record', 'Record the application server session to the given file.') do |filename| # nop, hack fix. end opts.on('--playback', 'Playback a previously recorded session from the given file.') do |filename| # nop, hack fix. end opts.on('--cluster', 'Setup a cluster.') do |ic| # nop, hack fix. end end parser.parse!(ARGV) return self end |