70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/ydim/server.rb', line 70
def initialize(config, logger)
@serv = Needle::Registry.new
@serv.register(:auth_server) {
auth = RRBA::Server.new
root = RootUser.new(:root)
root.name = config.root_name
root.email = config.root_email
root_key = config.root_key
path = File.expand_path(root_key, config.conf_dir)
path_or_key = File.exist?(path) ? path : root_key
root.public_key = Util.load_key(path_or_key)
auth.root = root
auth
}
@serv.register(:clients) {
ClientHandler.new(@serv)
}
@serv.register(:config) {
config
}
@serv.register(:currency_converter) {
ODBA.cache.fetch_named('currency_converter', self) {
CurrencyConverter.new
}
}
@serv.register(:factory) {
Factory.new(@serv)
}
@serv.register(:id_server) {
ODBA.cache.fetch_named('id_server', self) {
ODBA::IdServer.new
}
}
@serv.register(:logger) {
logger
}
if(hour = config.autoinvoice_hour)
@autoinvoicer = repeat_at(hour, 'AutoInvoicer') {
AutoInvoicer.new(@serv).run
}
end
if(hour = config.currency_update_hour)
if(@serv.currency_converter.known_currencies \
< @serv.config.currencies.size)
CurrencyUpdater.new(@serv).run
end
@currency_updater = repeat_at(hour, 'CurrencyUpdater') {
CurrencyUpdater.new(@serv).run
}
end
@status_updater = repeat_at(1, 'StatusUpdater') {
Invoice.all { |inv| inv.save }
}
@sessions = []
end
|