Class: Bluth::CLI
- Inherits:
-
Drydock::Command
- Object
- Drydock::Command
- Bluth::CLI
- Defined in:
- lib/bluth/cli.rb
Instance Method Summary collapse
- #replace_worker(worker_class = Bluth::Worker) ⇒ Object
- #schedulers ⇒ Object
- #start_scheduler ⇒ Object
-
#start_worker(worker_class = Bluth::Worker) ⇒ Object
def flush_workers if @global.auto || Annoy.are_you_sure? Bluth::Worker.prefix end end.
- #start_workers ⇒ Object
- #stop_scheduler ⇒ Object
- #stop_worker(wid = nil, worker_class = Bluth::Worker) ⇒ Object
- #stop_workers(worker_class = Bluth::Worker) ⇒ Object
- #workers(worker_class = Bluth::Worker) ⇒ Object
Instance Method Details
#replace_worker(worker_class = Bluth::Worker) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bluth/cli.rb', line 57 def replace_worker worker_class=Bluth::Worker Bluth.connect workers = worker_class.instances.members.select { |w| w.host == Bluth.sysinfo.hostname } if workers.empty? Familia.info "No workers running on #{Bluth.sysinfo.hostname}" else workers.sort! { |a,b| a.created <=> b.created } oldest_worker = workers.first Familia.info "Replacing #{oldest_worker.index}/#{oldest_worker.pid} (running since #{Time.at(oldest_worker.created).utc})" kill_worker oldest_worker, worker_class @global.daemon = true start_worker worker_class end end |
#schedulers ⇒ Object
19 20 21 |
# File 'lib/bluth/cli.rb', line 19 def schedulers workers Bluth.scheduler end |
#start_scheduler ⇒ Object
11 12 13 |
# File 'lib/bluth/cli.rb', line 11 def start_scheduler start_worker Bluth.scheduler end |
#start_worker(worker_class = Bluth::Worker) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bluth/cli.rb', line 29 def start_worker worker_class=Bluth::Worker if @global.daemon worker = worker_class.new Familia.info "Created: #{worker.index}" worker.daemonize worker.run else Bluth.queuetimeout = 3.seconds worker_class.run end end |
#start_workers ⇒ Object
7 8 9 |
# File 'lib/bluth/cli.rb', line 7 def start_workers start_worker end |
#stop_scheduler ⇒ Object
15 16 17 |
# File 'lib/bluth/cli.rb', line 15 def stop_scheduler stop_workers Bluth.scheduler end |
#stop_worker(wid = nil, worker_class = Bluth::Worker) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/bluth/cli.rb', line 48 def stop_worker wid=nil, worker_class=Bluth::Worker Bluth.connect wids = wid ? [wid] : @argv wids.each do |wid| worker = worker_class.from_redis wid kill_worker worker, worker_class end end |
#stop_workers(worker_class = Bluth::Worker) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/bluth/cli.rb', line 41 def stop_workers worker_class=Bluth::Worker Bluth.connect worker_class.instances.each do |worker| kill_worker worker, worker_class end end |
#workers(worker_class = Bluth::Worker) ⇒ Object
72 73 74 |
# File 'lib/bluth/cli.rb', line 72 def workers worker_class=Bluth::Worker Familia.info worker_class.all.collect &:index end |