2014-12-22 14:22:04 +03:00
|
|
|
require "wisper"
|
2014-05-08 15:34:26 +04:00
|
|
|
|
|
|
|
|
$:.push File.dirname(__FILE__)
|
|
|
|
|
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-11-26 18:46:04 +03:00
|
|
|
require "db/mongo/mongo_connector"
|
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-06-25 11:13:46 +03:00
|
|
|
require "loader"
|
|
|
|
|
require "devops_db"
|
2015-07-10 15:00:13 +03:00
|
|
|
require "devops_logger"
|
|
|
|
|
|
2015-01-26 15:02:58 +03:00
|
|
|
require_relative "routes/v2.0"
|
2015-06-25 11:13:46 +03:00
|
|
|
|
|
|
|
|
require "hooks"
|
|
|
|
|
require "app/devops-application"
|
|
|
|
|
require "app/devops-client"
|
|
|
|
|
require "app/sidekiq_web"
|
|
|
|
|
require "app/devops-version"
|
|
|
|
|
require "app/devops-api2"
|
2014-05-08 15:34:26 +04:00
|
|
|
|
2015-02-18 13:15:25 +03:00
|
|
|
require_relative "sinatra/methods_with_headers"
|
|
|
|
|
|
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-02-06 17:21:13 +03:00
|
|
|
def routes
|
|
|
|
|
config = DevopsConfig.config
|
|
|
|
|
Devops::Routes.preffix = config[:url_prefix]
|
2015-06-25 11:13:46 +03:00
|
|
|
#require_relative "routes/routes.rb"
|
2014-05-08 15:34:26 +04:00
|
|
|
end
|
|
|
|
|
|
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-07-10 15:00:13 +03:00
|
|
|
DevopsLogger.create STDOUT
|
|
|
|
|
|
2015-06-25 11:13:46 +03:00
|
|
|
routes
|
|
|
|
|
apps = Devops::Application::Application.applications
|
|
|
|
|
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
|
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
|
|
|
|
|
|
|
|
require "wisper_fix"
|