Permalink
Newer
Older
100755 48 lines (38 sloc) 1.33 KB
1
#!/usr/bin/env ruby
2
3
RAILS_HOME = File.expand_path(File.join(File.dirname(__FILE__),".."))
4
BDRB_HOME = File.join(RAILS_HOME,"vendor","plugins","backgroundrb")
5
WORKER_ROOT = File.join(RAILS_HOME,"lib","workers")
6
WORKER_LOAD_ENV = File.join(RAILS_HOME,"script","load_worker_env")
8
["server","server/lib","lib","lib/backgroundrb"].each { |x| $LOAD_PATH.unshift(BDRB_HOME + "/#{x}")}
9
$LOAD_PATH.unshift(WORKER_ROOT)
10
12
require RAILS_HOME + "/config/boot"
13
require "active_support"
Jun 20, 2008
16
BDRB_CONFIG = BackgrounDRb::Config.read_config("#{RAILS_HOME}/config/backgroundrb.yml")
17
PID_FILE = "#{RAILS_HOME}/tmp/pids/backgroundrb_#{BDRB_CONFIG[:backgroundrb][:port]}.pid"
Jun 20, 2008
18
SERVER_LOGGER = "#{RAILS_HOME}/log/backgroundrb_debug_#{BDRB_CONFIG[:backgroundrb][:port]}.log"
21
daemon = BackgrounDRb::StartStop.new
23
case ARGV[0]
24
when 'start'; daemon.start
25
when 'stop'; daemon.stop
26
when 'restart'; daemon.stop;daemon.start
27
when 'status'
28
if daemon.running?
29
puts "BackgrounDRb Running"
30
exit
31
else
32
puts "BackgrounDRb Not Running"
33
exit!(daemon.status)
34
end
35
else
36
require "logger"
37
require "packet"
38
require "optparse"
39
40
BackgrounDRb::Config.parse_cmd_options ARGV
41
42
require RAILS_HOME + "/config/environment"
43
require "bdrb_job_queue"
44
require "backgroundrb_server"
46
end