Module: Bj::Runner::ClassMethods
- Defined in:
- lib/bj/runner.rb
Instance Method Summary collapse
- #background ⇒ Object
- #background=(value) ⇒ Object
- #command ⇒ Object
- #key(ppid = 0) ⇒ Object
- #log ⇒ Object
- #logdir ⇒ Object
- #no_tickle_key ⇒ Object
- #ping ⇒ Object
- #run(options = {}, &block) ⇒ Object
- #start(options = {}) ⇒ Object
- #tickle ⇒ Object
Instance Method Details
#background ⇒ Object
113 114 115 |
# File 'lib/bj/runner.rb', line 113 def background @background ||= Hash.new end |
#background=(value) ⇒ Object
117 118 119 |
# File 'lib/bj/runner.rb', line 117 def background= value @background ||= value end |
#command ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/bj/runner.rb', line 121 def command "#{ Bj.ruby } " + %W[ #{ Bj.script } run --forever --redirect=#{ log } --ppid=#{ Process.pid } --rails_env=#{ Bj.rails_env } --rails_root=#{ Bj.rails_root } ].map{|word| word.inspect}.join(" ") end |
#key(ppid = 0) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/bj/runner.rb', line 95 def key ppid = 0 ppid ||= 0 # "#{ Bj.rails_env }.#{ ppid }.pid" # "runner.#{ ppid }.pid" Bj.rails_env end |
#log ⇒ Object
133 134 135 |
# File 'lib/bj/runner.rb', line 133 def log File.join logdir, "bj.#{ Bj.hostname }.#{ Bj.rails_env }.log" end |
#logdir ⇒ Object
137 138 139 |
# File 'lib/bj/runner.rb', line 137 def logdir File.join File.(Bj.rails_root), 'log' end |
#no_tickle_key ⇒ Object
102 103 104 105 |
# File 'lib/bj/runner.rb', line 102 def no_tickle_key # "#{ Bj.rails_env }.no_tickle" "no_tickle" end |
#ping ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/bj/runner.rb', line 65 def ping begin pid = nil uri = nil process = nil Bj.transaction do pid = Bj.config[Runner.key(Process.pid)] || Bj.config[Runner.key] uri = Bj.config["#{ pid }.uri"] process = if uri require "drb" # DRb.start_service "druby://localhost:0" DRbObject.new(nil, uri) else Process end end return nil unless pid pid = Integer pid begin process.kill Runner.hup_signal, pid pid rescue Exception => e false end rescue Exception => e false end end |
#run(options = {}, &block) ⇒ Object
141 142 143 |
# File 'lib/bj/runner.rb', line 141 def run = {}, &block new(, &block).run end |
#start(options = {}) ⇒ Object
107 108 109 110 111 |
# File 'lib/bj/runner.rb', line 107 def start = {} . background.delete Bj.rails_env if [:force] background[Bj.rails_env] ||= Background.for(command) end |