Class: MKIt::HAProxyWorker

Inherits:
AWorker
  • Object
show all
Defined in:
lib/mkit/workers/haproxy_worker.rb

Instance Method Summary collapse

Methods inherited from AWorker

#initialize

Constructor Details

This class inherits a constructor from MKIt::AWorker

Instance Method Details

#do_the(job) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mkit/workers/haproxy_worker.rb', line 8

def do_the(job)
  MKItLogger.info("#{self.class} working on the job #{job.inspect}....")
  unless job.service_id.nil?
    srv = Service.find(job.service_id)
    config = srv.proxy_config
  end
  case job.topic.to_sym
  when :update_proxy_config
    MKItLogger.debug config.inspect
    MKIt::HAProxy.create_config_file(filename: config[:filename], data: config[:data])
    MKIt::HAProxy.reload
  when :destroy_proxy_config
    MKIt::HAProxy.delete_config_file(filename: job.data['filename'])
    MKIt::HAProxy.reload
  when :create_proxy_config
    MKIt::HAProxy.create_config_file(filename: config[:filename], data: config[:data])
    MKIt::HAProxy.reload
  when :reload_proxy
    MKIt::HAProxy.reload
  when :restart_proxy
    MKIt::HAProxy.restart
  else
    MKItLogger.warn("#{self.class} <<TODO>> job #{job.inspect}....")
  end
end

#topicsObject



4
5
6
# File 'lib/mkit/workers/haproxy_worker.rb', line 4

def topics
  %w{create_proxy_config destroy_proxy_config update_proxy_config restart_proxy reload_proxy}
end