Sha256: daa2fef88c22bb8bb3ef8b1e4a6ba02da37ffb238a119b96ef894da13f907c41
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
#!/usr/bin/env ruby require 'facets/more/consoleapp' class NitroCommand < Console::Command # :section: Commands # The default action, starts the application. You can # alternatively use the start/run aliases. # # === Examples # # $ nitro # $ nitro start # $ nitro run def default if f = application_file $NITRO_NO_ENVIRONMENT = true load 'run.rb' else puts 'No application found!' # FIXME: better error mesage and/or show default app! end end alias run default alias start default # Starts an IRB console attached to the web application. def console if RUBY_PLATFORM =~ /mswin32/ irb_name = 'irb.bat' else irb_name = 'irb' end ENV['NITRO_INVOKE'] = 'irb' if f = application_file ENV['NITRO_MODE'] = $DBG ? 'debug' : 'live' exec "#{irb_name} -r #{f} -r irb/completion --noinspect" end exit end # Dump the version of Nitro. def version puts "Nitro 0.31.0" end # :section: Options # Enable verbose mode. def _v $DBG = true ENV['NITRO_MODE'] = 'debug' end alias _verbose _v # Daemonize the server. Typically used with the Webrick # adapter. def _daemon require 'daemons/daemonize' pwd = Dir.pwd Daemonize.daemonize(File.join(pwd, 'log/app.log')) # Restore the original pwd (daemonize sets the # pwd to '/'). Dir.chdir(pwd) # Set the logger to a file (daemonize closes the # std streams). Logger.set(Logger.new('log/app.log')) end alias _daemonize _daemon private # Typical application main file names. APPLICATION_FILES = %w{ run.rb start.rb conf.rb app.rb application.rb } # Find out the application main file. def application_file for f in APPLICATION_FILES if File.exist? f return f end end return false end end NitroCommand.new.execute # * George Moschovitis <gm@navel.gr>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.31.0 | bin/nitro |