Module: FakeGoUp

Defined in:
lib/fake_go_up.rb,
lib/fake_go_up/task.rb,
lib/fake_go_up/version.rb

Defined Under Namespace

Classes: Task

Constant Summary collapse

DEFAULT_PID_NAME =
"FakeGoUp"
VERSION =
"0.1.1"
@@redis =
nil

Class Method Summary collapse

Class Method Details

._runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fake_go_up.rb', line 26

def _run
  tasks = FakeGoUp::Task.subclasses.map(&:new)
  while true
    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

.redisObject



41
42
43
# File 'lib/fake_go_up.rb', line 41

def redis
  @@redis
end

.redis=(conn) ⇒ Object



11
12
13
# File 'lib/fake_go_up.rb', line 11

def redis=(conn)
  @@redis = conn
end

.run(pid_name = DEFAULT_PID_NAME) ⇒ Object



15
16
17
18
19
20
# File 'lib/fake_go_up.rb', line 15

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



22
23
24
# File 'lib/fake_go_up.rb', line 22

def stop(pid_name = DEFAULT_PID_NAME)
  PidLock.stop(pid_name)
end