2014-12-22 14:22:04 +03:00
|
|
|
require "wisper"
|
2014-05-08 15:34:26 +04:00
|
|
|
|
2015-07-16 12:54:16 +03:00
|
|
|
=begin
|
2014-05-08 15:34:26 +04:00
|
|
|
require "db/exceptions/invalid_record"
|
|
|
|
|
require "db/exceptions/record_not_found"
|
2014-12-22 14:22:04 +03:00
|
|
|
require "exceptions/dependency_error"
|
2014-11-26 16:59:46 +03:00
|
|
|
require "db/validators/all"
|
2014-05-08 15:34:26 +04:00
|
|
|
require "providers/provider_factory"
|
|
|
|
|
|
2015-02-12 13:30:49 +03:00
|
|
|
require "fog"
|
2014-12-12 17:00:06 +03:00
|
|
|
|
2015-01-26 15:02:58 +03:00
|
|
|
require_relative "routes/v2.0"
|
2015-06-25 11:13:46 +03:00
|
|
|
|
|
|
|
|
require "hooks"
|
2015-07-16 12:54:16 +03:00
|
|
|
=end
|
|
|
|
|
|
|
|
|
|
require_relative "devops-loader"
|
|
|
|
|
require_relative "devops-db"
|
|
|
|
|
require_relative "devops-logger"
|
|
|
|
|
require_relative "devops-application"
|
|
|
|
|
|
2015-08-12 09:41:19 +03:00
|
|
|
require "lib/knife/knife_factory"
|
2015-08-11 19:47:54 +03:00
|
|
|
|
2015-07-16 12:54:16 +03:00
|
|
|
require_relative "../sinatra/methods_with_headers"
|
2014-05-08 15:34:26 +04:00
|
|
|
|
2015-07-16 12:54:16 +03:00
|
|
|
require_relative "../applications"
|
|
|
|
|
#root = File.expand_path("../", __FILE__)
|
|
|
|
|
#$:.push root
|
2015-02-18 13:15:25 +03:00
|
|
|
|
2015-01-26 15:02:58 +03:00
|
|
|
class DevopsService
|
2014-12-15 14:26:54 +03:00
|
|
|
|
2014-12-22 14:22:04 +03:00
|
|
|
include Wisper::Publisher
|
|
|
|
|
|
2015-01-26 15:02:58 +03:00
|
|
|
class << self
|
2014-12-15 14:26:54 +03:00
|
|
|
|
2015-03-03 12:46:35 +03:00
|
|
|
# steps:
|
|
|
|
|
# 1. init db
|
|
|
|
|
# 2. load application handlers
|
|
|
|
|
# 3. load plugins
|
|
|
|
|
# 4. load application routes
|
|
|
|
|
# 5. add plugins routes
|
|
|
|
|
# 6. init all routes classes
|
|
|
|
|
# 7. register routes for all classes
|
2015-02-06 17:21:13 +03:00
|
|
|
def init
|
|
|
|
|
# init database
|
|
|
|
|
Devops::Db.init
|
2015-08-07 13:06:59 +03:00
|
|
|
DevopsLogger.logger = DevopsLogger.create(STDOUT)
|
2015-07-10 15:00:13 +03:00
|
|
|
|
2015-08-13 17:43:08 +03:00
|
|
|
config = DevopsConfig.config
|
|
|
|
|
Devops::Routes.preffix = config[:url_prefix]
|
|
|
|
|
|
2015-07-16 12:54:16 +03:00
|
|
|
apps = Devops::Application.applications
|
2015-06-25 11:13:46 +03:00
|
|
|
apps.each do |a|
|
|
|
|
|
a.prepare
|
|
|
|
|
end
|
|
|
|
|
|
2015-06-30 14:27:42 +03:00
|
|
|
Devops::Loader.prepare_plugins
|
2015-06-25 11:13:46 +03:00
|
|
|
apps.each do |a|
|
|
|
|
|
a.init
|
|
|
|
|
end
|
2015-02-06 17:21:13 +03:00
|
|
|
Devops::Loader.init_plugins
|
2015-06-25 11:13:46 +03:00
|
|
|
apps.each do |a|
|
|
|
|
|
a.routes
|
|
|
|
|
end
|
|
|
|
|
Devops::Loader.routes
|
|
|
|
|
=begin
|
|
|
|
|
Devops::Version2_0::Application.load
|
|
|
|
|
Devops::Loader.load_plugins
|
2015-02-06 17:21:13 +03:00
|
|
|
# init routes classes
|
|
|
|
|
Devops::Version2_0::Application.init
|
2015-06-25 11:13:46 +03:00
|
|
|
# init plugins
|
|
|
|
|
Devops::Loader.init_plugins
|
2015-02-06 17:21:13 +03:00
|
|
|
Devops::Version2_0::Application.register_routes
|
|
|
|
|
# init routes paths
|
|
|
|
|
routes
|
|
|
|
|
# add plugins routes
|
|
|
|
|
Devops::Loader.routes
|
2015-06-25 11:13:46 +03:00
|
|
|
=end
|
2015-08-13 17:43:08 +03:00
|
|
|
KnifeFactory.init
|
2014-05-08 15:34:26 +04:00
|
|
|
end
|
2015-02-12 13:30:49 +03:00
|
|
|
|
|
|
|
|
def debug?
|
|
|
|
|
DevopsConfig.config[:debug]
|
|
|
|
|
end
|
2014-05-08 15:34:26 +04:00
|
|
|
end
|
|
|
|
|
|
2014-12-22 14:22:04 +03:00
|
|
|
def self.create_method name, &block
|
|
|
|
|
send(:generate_method, name, &block)
|
|
|
|
|
end
|
|
|
|
|
|
2014-05-08 15:34:26 +04:00
|
|
|
end
|
2014-12-22 14:22:04 +03:00
|
|
|
|
2015-07-16 12:54:16 +03:00
|
|
|
require_relative "../wisper_fix"
|