Class: Cronicle::Client
- Inherits:
-
Object
- Object
- Cronicle::Client
- Includes:
- Logger::Helper
- Defined in:
- lib/cronicle/client.rb
Constant Summary collapse
- DEFAULTS =
{ :concurrency => 10, :var_dir => '/var/lib/cronicle' }
Instance Method Summary collapse
- #apply(file) ⇒ Object
- #cleanup ⇒ Object
- #exec(file, name) ⇒ Object
-
#initialize(host_list, options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Logger::Helper
Constructor Details
Instance Method Details
#apply(file) ⇒ Object
14 15 16 |
# File 'lib/cronicle/client.rb', line 14 def apply(file) walk(file) end |
#cleanup ⇒ Object
18 19 20 |
# File 'lib/cronicle/client.rb', line 18 def cleanup walk(nil, :cleanup => true) end |
#exec(file, name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cronicle/client.rb', line 22 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 @options[:ssh_user] and host !~ /@/ host = @options[: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 |