fluke/devops-service/core/devops-service.rb

69 lines
1.5 KiB
Ruby
Raw Normal View History

2016-01-19 18:11:07 +03:00
require "lib/core_ext/hash"
require "lib/core_ext/nil_class"
require "lib/core_ext/string"
2014-05-08 15:34:26 +04:00
2015-07-16 12:54:16 +03:00
require_relative "devops-loader"
require_relative "devops-application"
2015-07-16 12:54:16 +03:00
require_relative "devops-db"
require_relative "devops-logger"
2015-09-22 12:19:15 +03:00
require_relative "devops-messages"
2015-07-16 12:54:16 +03:00
2018-04-04 22:44:39 +03:00
require "providers/provider.rb"
require "lib/ssh/ssh_utils"
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"
2015-08-19 19:51:53 +03:00
require_relative "devops-routes"
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
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 init
2018-04-04 22:44:39 +03:00
Devops::Db.init(Sinatra::Base.environment)
DevopsLogger.logger = DevopsLogger.create($stdout)
2018-04-04 22:44:39 +03:00
if DevopsConfig.config[:url_prefix].nil?
DevopsConfig.config[:url_prefix] = ""
elsif !DevopsConfig.config[:url_prefix].empty?
DevopsConfig.config[:url_prefix] = "/" + DevopsConfig.config[:url_prefix] unless DevopsConfig.config[:url_prefix].start_with?("/")
end
Devops::Routes.preffix = DevopsConfig.config[:url_prefix]
2015-09-22 12:19:15 +03:00
Devops::Messages.init
2015-08-13 17:43:08 +03:00
2018-04-04 22:44:39 +03:00
load_apps
prepare_apps_and_plugins
init_apps_and_plugins
load_routes
KnifeFactory.init
end
def load_apps
@apps = Devops::Application.applications
end
2015-06-25 11:13:46 +03:00
2018-04-04 22:44:39 +03:00
def prepare_apps_and_plugins
@apps.each(&:prepare)
2015-06-30 14:27:42 +03:00
Devops::Loader.prepare_plugins
2018-04-04 22:44:39 +03:00
end
def init_apps_and_plugins
@apps.each(&:init)
2015-06-25 11:13:46 +03:00
Devops::Loader.init_plugins
2018-04-04 22:44:39 +03:00
end
def load_routes
@apps.each(&:routes)
2015-02-06 17:21:13 +03:00
Devops::Loader.routes
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
end