Class: Nginx::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/nginx/manager.rb

Class Method Summary collapse

Class Method Details

.add(ports) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nginx/manager.rb', line 17

def add(ports)
  ports = [*ports]
  $logger.info "adding #{ports} to nginx"
  modify_nginx do |ofile, iline|
    ofile.puts(iline)
    if iline =~ /upstream phantomjs/
      ports.each do |port|
        ofile.puts(phantom_upstream(port)) unless port_defined?(port)
      end
    end
  end
end

.remove(ports) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/nginx/manager.rb', line 9

def remove(ports)
  ports = [*ports]
  $logger.info "removing #{ports} from nginx"
  modify_nginx do |ofile, iline|
    ofile.puts(iline) if !line_matches_ports(iline, ports)
  end
end