Class: ConfigTool

### Home Classes Methods

### In Files

- lib/mongrel_config/init.rb

### Parent

GemPlugin::Plugin"/commands"

### Methods

- #configure
- #run
- #validate

### Included Modules

- Mongrel::Command::Base

### Class/Module Index

Quicksearch

- Configure
- Configure::Controllers
- Configure::Controllers::ClearLogs
- Configure::Controllers::Delete
- Configure::Controllers::Index
- Configure::Controllers::Info
- Configure::Controllers::Install
- Configure::Controllers::Kill
- Configure::Controllers::Logs
- Configure::Controllers::Start
- Configure::Controllers::Stop
- Configure::Views
- ConfigTool
- W32Support

No matching classes.

# ConfigTool

### Public Instance Methods

configure() click to toggle source

    # File lib/mongrel_config/init.rb, line 9
    def configure
      if RUBY_PLATFORM =~ /mswin/
        options [
          ['-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
        options [
          ['-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() click to toggle source

    # 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() click to toggle source

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.