Class: Property::Nginx

Inherits:
Property
  • Object
show all
Defined in:
app/models/property/nginx.rb

Instance Attribute Summary

Attributes inherited from Property

#collection, #multiple, #translate

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Property

add, all_new_values, all_new_values_for_write, all_to_show, #has_new_value?, #input_type, #set_value

Class Method Details

.render_rmails_site_template(a, site, key_value_string) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/property/nginx.rb', line 7

def self.render_rmails_site_template(a, site, key_value_string)
  # example key_value_string= 'hostnames=rmails.com www.rmails.com;a=b;c=d'
  locals = Hash[ key_value_string.split(';').map  {|it|  it.split('=', 2)  } ]
  site_path = "#{etc_nginx}/#{sites_available}/#{site}"
  render(
    :file   => "#{dist}nginx/rmails.erb",
    :to     => site_path,
    :mode   => 0664,
    :locals => {:rails_root => Rails.root}.merge(locals)
  )
end

.serviceObject



3
# File 'app/models/property/nginx.rb', line 3

def self.service; NGINX ;end

Instance Method Details

#site_power(a, site, run) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/property/nginx.rb', line 19

def site_power(a, site, run)
  site_enabled = "#{etc_nginx}/#{sites_enabled}/#{site}"
  if run
    unless File.file? site_enabled
      a.shell_manager.ln_s  "#{etc_nginx}/#{sites_available}/#{site}",
                            site_enabled
    end
  else
    a.shell_manager.rm site_enabled
  end
end