| 
									
										
										
										
											2014-12-22 14:22:04 +03:00
										 |  |  | require "wisper" | 
					
						
							| 
									
										
										
										
											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" | 
					
						
							| 
									
										
										
										
											2015-08-28 14:44:28 +03:00
										 |  |  | 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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" | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-09-22 12:19:15 +03:00
										 |  |  |       Devops::Messages.init | 
					
						
							| 
									
										
										
										
											2015-08-13 17:43:08 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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" |