Class: Configure::Controllers::Install

Inherits:
R
  • Object
show all
Defined in:
lib/mongrel_config/win32_app.rb

Instance Method Summary collapse

Instance Method Details

#bad?(field) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/mongrel_config/win32_app.rb', line 113

def bad?(field)
  not good? field
end

#getObject



76
77
78
# File 'lib/mongrel_config/win32_app.rb', line 76

def get
  render :install_form
end

#good?(field) ⇒ Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/mongrel_config/win32_app.rb', line 109

def good?(field)
  field and not field.strip.empty?
end

#postObject



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
# File 'lib/mongrel_config/win32_app.rb', line 80

def post
  options = []
  if bad?(input.service_name) or bad?(input.root) or bad?(input.environment) or bad?(input.address) or bad?(input.port)
    @result = "ERROR: You must fill out all mandatory (*) fields."
    render :install_result
  else
    options << ["-n", input.service_name]
    options << ["-r", '"' + input.root + '"']
    options << ["-e", input.environment]
    options << ["-b", input.address]
    options << ["-p", input.port]
    options << ["-d", input.display_name] if good? input.display_name
    options << ["-m", '"' + input.mime + '"'] if good? input.mime
    options << ["-P", input.num_procs] if good? input.num_procs
    options << ["-t", input.timeout] if good? input.timeout
    options << ["-c", input.cpu] if good? input.cpu
    
    begin
      @result = `ruby #$mongrel_rails_service install #{options.join(' ')}`
      $service_logs << @result
    rescue
      @result = "Failed to start #{input.service_name}: #$!"
      $service_logs << @result
    end
    
    render :install_result
  end
end