Class: BBMB::Util::App

Inherits:
SBSM::App
  • Object
show all
Defined in:
lib/bbmb/util/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApp



60
61
62
63
64
65
66
# File 'lib/bbmb/util/app.rb', line 60

def initialize
    super
    puts "Starting Rack-Service #{self.class} and service #{BBMB.config.server_url}"
    Thread.new {
        start_service
    }
end

Instance Attribute Details

#db_managerObject

Returns the value of attribute db_manager.



29
30
31
# File 'lib/bbmb/util/app.rb', line 29

def db_manager
  @db_manager
end

#yus_serverObject

Returns the value of attribute yus_server.



29
30
31
# File 'lib/bbmb/util/app.rb', line 29

def yus_server
  @yus_server
end

Instance Method Details

#start_serviceObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/bbmb/util/app.rb', line 30

def start_service
  case BBMB.config.persistence
  when 'odba'
    DRb.install_id_conv ODBA::DRbIdConv.new
    BBMB.persistence = BBMB::Persistence::ODBA
  end
  BBMB.auth = DRb::DRbObject.new(nil, BBMB.config.auth_url)
  puts "installed BBMB.auth for #{BBMB.config.auth_url}"
  BBMB.server = BBMB::Util::Server.new(BBMB.persistence, self)
  BBMB.server.extend(DRbUndumped)
  BBMB.server = BBMB.server
  puts "installed BBMB.server #{BBMB.server}"
  if(BBMB.config.update?)
    BBMB.server.run_updater
  end
  if(BBMB.config.invoice?)
    BBMB.server.run_invoicer
  end
  url = BBMB.config.server_url
  url.untaint
  DRb.start_service(url, BBMB.server)
  $SAFE = 1
  $0 = BBMB.config.name
  SBSM.logger.info('start') { sprintf("starting bbmb-server on %s", url) }
  DRb.thread.join
  SBSM.logger.info('finished') { sprintf("starting bbmb-server on %s", url) }
rescue Exception => error
  SBSM.logger.error('fatal') { error }
  raise
end