Class: H2OConfigurator::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/h2o-configurator/builder.rb

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



20
21
22
# File 'lib/h2o-configurator/builder.rb', line 20

def initialize
  H2OLogDir.mkpath
end

Instance Method Details

#check_configObject



45
46
47
48
# File 'lib/h2o-configurator/builder.rb', line 45

def check_config
  system('h2o', '-t', '-c', H2OConfFile.to_s)
  exit($?.to_i) unless $?.success?
end

#make_configObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/h2o-configurator/builder.rb', line 24

def make_config
  config = {
    'compress' => 'ON',
    'reproxy' => 'ON',
    'error-log' => ErrorLogFile.to_s,
    'hosts' => {},
  }
  Path.glob(SitesDirGlob).reject { |p| p.extname == '.old' || p.extname == '.new' }.each do |site_dir|
    site = Site.new(site_dir)
    config['hosts'].merge!(site.make_config)
  end
  config
end

#write_configObject



38
39
40
41
42
43
# File 'lib/h2o-configurator/builder.rb', line 38

def write_config
  RedirectHandlerFile.copy(InstalledRedirectHandlerFile)
  AutoExtensionHandlerFile.copy(InstalledAutoExtensionHandlerFile)
  H2OConfFile.write(YAML.dump(make_config))
  check_config
end