95 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require "wisper"
 | |
| 
 | |
| =begin
 | |
| require "db/exceptions/invalid_record"
 | |
| require "db/exceptions/record_not_found"
 | |
| require "exceptions/dependency_error"
 | |
| require "db/validators/all"
 | |
| require "providers/provider_factory"
 | |
| 
 | |
| require "fog"
 | |
| 
 | |
| require_relative "routes/v2.0"
 | |
| 
 | |
| require "hooks"
 | |
| =end
 | |
| 
 | |
| require_relative "devops-loader"
 | |
| require_relative "devops-db"
 | |
| require_relative "devops-logger"
 | |
| require_relative "devops-application"
 | |
| 
 | |
| require "lib/knife/knife_factory"
 | |
| 
 | |
| require_relative "../sinatra/methods_with_headers"
 | |
| 
 | |
| require_relative "../applications"
 | |
| require_relative "devops-routes"
 | |
| #root = File.expand_path("../", __FILE__)
 | |
| #$:.push root
 | |
| 
 | |
| class DevopsService
 | |
| 
 | |
|   include Wisper::Publisher
 | |
| 
 | |
|   class << self
 | |
| 
 | |
|     # 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
 | |
|     def init
 | |
|       # init database
 | |
|       Devops::Db.init
 | |
|       DevopsLogger.logger = DevopsLogger.create(STDOUT)
 | |
| 
 | |
|       config = DevopsConfig.config
 | |
|       Devops::Routes.preffix = config[:url_prefix]
 | |
| 
 | |
|       apps = Devops::Application.applications
 | |
|       apps.each do |a|
 | |
|         a.prepare
 | |
|       end
 | |
| 
 | |
|       Devops::Loader.prepare_plugins
 | |
|       apps.each do |a|
 | |
|         a.init
 | |
|       end
 | |
|       Devops::Loader.init_plugins
 | |
|       apps.each do |a|
 | |
|         a.routes
 | |
|       end
 | |
|       Devops::Loader.routes
 | |
| =begin
 | |
|       Devops::Version2_0::Application.load
 | |
|       Devops::Loader.load_plugins
 | |
|       # init routes classes
 | |
|       Devops::Version2_0::Application.init
 | |
|       # init plugins
 | |
|       Devops::Loader.init_plugins
 | |
|       Devops::Version2_0::Application.register_routes
 | |
|       # init routes paths
 | |
|       routes
 | |
|       # add plugins routes
 | |
|       Devops::Loader.routes
 | |
| =end
 | |
|       KnifeFactory.init
 | |
|     end
 | |
| 
 | |
|     def debug?
 | |
|       DevopsConfig.config[:debug]
 | |
|     end
 | |
|   end
 | |
| 
 | |
|   def self.create_method name, &block
 | |
|     send(:generate_method, name, &block)
 | |
|   end
 | |
| 
 | |
| end
 | |
| 
 | |
| require_relative "../wisper_fix"
 | 
