Class: Cronicle::Client
- Inherits:
-
Object
- Object
- Cronicle::Client
- Includes:
- Logger::Helper
- Defined in:
- lib/cronicle/client.rb
Constant Summary collapse
- DEFAULTS =
{ :concurrency => 10, :libexec => '/var/lib/cronicle/libexec' }
Instance Method Summary collapse
- #apply(file) ⇒ Object
- #exec(file, name) ⇒ Object
-
#initialize(host_list, options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Logger::Helper
Constructor Details
#initialize(host_list, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/cronicle/client.rb', line 9 def initialize(host_list, = {}) @host_list = host_list = DEFAULTS.merge() end |
Instance Method Details
#apply(file) ⇒ Object
14 15 16 |
# File 'lib/cronicle/client.rb', line 14 def apply(file) walk(file) end |
#exec(file, name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cronicle/client.rb', line 18 def exec(file, name) name = name.to_s jobs = load_file(file) jobs_by_host = select_host(jobs, name) if jobs_by_host.empty? raise "Definition cannot be found: Job `#{name}`" end parallel_each(jobs_by_host) do |host, jobs_by_user| if [:ssh_user] and host !~ /@/ host = [:ssh_user] + '@' + host end run_driver(host) do |driver| jobs_by_user.each do |user, jobs| driver.execute_job(user, jobs) end end end end |