Module: Bj::Runner::ClassMethods

Defined in:
lib/bj/runner.rb

Instance Method Summary collapse

Instance Method Details

#backgroundObject



70
71
72
# File 'lib/bj/runner.rb', line 70

def background
  @background ||= Hash.new
end

#commandObject



74
75
76
# File 'lib/bj/runner.rb', line 74

def command
  "#{ Bj.ruby } #{ Bj.script } run --forever --redirect=#{ log } --rails_env=#{ Bj.rails_env } --ppid=#{ Process.pid }"
end

#keyObject



60
61
62
# File 'lib/bj/runner.rb', line 60

def key
  "#{ Bj.rails_env }.pid"
end

#logObject



78
79
80
# File 'lib/bj/runner.rb', line 78

def log
  File.join logdir, "bj.#{ Bj.hostname }.#{ Bj.rails_env }.log"
end

#logdirObject



82
83
84
# File 'lib/bj/runner.rb', line 82

def logdir
  File.join File.expand_path(Bj.rails_root), 'log'
end

#pingObject



55
56
57
58
# File 'lib/bj/runner.rb', line 55

def ping
  pid = Bj.config[Runner.key]
  pid ? Util.ping(pid) : nil
end

#run(options = {}, &block) ⇒ Object



86
87
88
# File 'lib/bj/runner.rb', line 86

def run options = {}, &block
  new(options, &block).run
end

#start(options = {}) ⇒ Object



64
65
66
67
68
# File 'lib/bj/runner.rb', line 64

def start options = {}
  options.to_options!
  background.delete Bj.rails_env if options[:force]
  background[Bj.rails_env] ||= Background.for(command)
end

#tickleObject



51
52
53
# File 'lib/bj/runner.rb', line 51

def tickle
  ping or start
end