Module: FakeGoUp
- Defined in:
- lib/fake_go_up.rb,
lib/fake_go_up/item.rb,
lib/fake_go_up/task.rb,
lib/fake_go_up/version.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_PID_NAME =
"FakeGoUp"
- VERSION =
"0.2.3"
- @@redis =
nil
Class Method Summary collapse
- ._run ⇒ Object
- .redis ⇒ Object
- .redis=(conn) ⇒ Object
- .run(pid_name = DEFAULT_PID_NAME) ⇒ Object
- .stop(pid_name = DEFAULT_PID_NAME) ⇒ Object
Class Method Details
._run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fake_go_up.rb', line 27 def _run tasks = FakeGoUp::Task.subclasses.map(&:new) running = true Signal.trap("TERM") do running = false end Signal.trap("QUIT") do running = false end while running all_finish = true tasks.each do |task| task.go_up all_finish = false unless task.all_finish? end break if all_finish sleep(1) end end |
.redis ⇒ Object
52 53 54 |
# File 'lib/fake_go_up.rb', line 52 def redis @@redis end |
.redis=(conn) ⇒ Object
12 13 14 |
# File 'lib/fake_go_up.rb', line 12 def redis=(conn) @@redis = conn end |
.run(pid_name = DEFAULT_PID_NAME) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/fake_go_up.rb', line 16 def run(pid_name = DEFAULT_PID_NAME) return if PidLock.locked?(pid_name) PidLock.lock(pid_name) _run PidLock.unlock(pid_name) end |
.stop(pid_name = DEFAULT_PID_NAME) ⇒ Object
23 24 25 |
# File 'lib/fake_go_up.rb', line 23 def stop(pid_name = DEFAULT_PID_NAME) PidLock.stop(pid_name) end |