Class: ConfigTool
- Inherits:
-
Object
- Object
- ConfigTool
- Includes:
- Mongrel::Command::Base
- Defined in:
- lib/mongrel_config/init.rb
Instance Method Summary collapse
Instance Method Details
#configure ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mongrel_config/init.rb', line 9 def configure if RUBY_PLATFORM =~ /mswin/ [ ['-h', '--host ADDR', "Host to bind to for server", :@host, "0.0.0.0"], ['-p', '--port NUMBER', "Port to bind to", :@port, "3001"], ['-u', '--uri URI', "Where to put your config tool", :@uri, "/config"], ['-R', '--mongrel PATH', "Path to mongrel_rails_service", :@mongrel_script, "c:\\ruby\\bin\\mongrel_rails_service"] ] else [ ['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd], ['-P', '--pid FILE', "Where to write the PID", :@pid_file, "log/mongrel.pid"], ['-h', '--host ADDR', "Host to bind to for server", :@host, "0.0.0.0"], ['-p', '--port NUMBER', "Port to bind to", :@port, "3001"], ['-u', '--uri URI', "Where to put your config tool", :@uri, "/config"] ] end end |
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/mongrel_config/init.rb', line 43 def run # must require this here since rails and camping don't like eachother if RUBY_PLATFORM =~ /mswin/ require 'mongrel_config/win32_app' $mongrel_rails_service = @mongrel_script else require 'mongrel_config/app' end resources = GemPlugin::Manager.instance.resource "mongrel_config", "/" $PID_FILE = @pid_file $server = Mongrel::Camping::start(@host,@port,@uri,Configure) puts "** Configure is running at http://#{@host}:#{@port}#{@uri}" if RUBY_PLATFORM !~ /mswin/ trap("INT") { $server.stop } puts "Use CTRL-C to quit." else puts "Use CTRL-Pause/Break to quit." end # add our log directory $server.register("/log", Mongrel::DirHandler.new("log")) $server.register("/config/resources", Mongrel::DirHandler.new(resources)) $server.acceptor.join end |
#validate ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mongrel_config/init.rb', line 28 def validate valid?(@uri, "Must give a uri") valid?(@port && @port.to_i > 0, "Must give a valid port") valid?(@host, "Host IP to bind must be given") if RUBY_PLATFORM !~ /mswin/ valid_dir? @cwd, "Cannot change to a directory that doesn't exist" Dir.chdir @cwd valid_dir? "log", "Log directory does not exist" end return @valid end |