Module: Volt::ServerSetup::App
- Included in:
- App
- Defined in:
- lib/volt/volt/server_setup/app.rb
Instance Method Summary collapse
- #load_app_code ⇒ Object
- #require_http_controllers ⇒ Object
- #reset_query_pool! ⇒ Object
-
#run_app_and_initializers ⇒ Object
Load in all .rb files in the initializers folders and the config/app.rb file.
-
#run_config ⇒ Object
This config needs to run earlier than others.
- #setup_paths ⇒ Object
- #setup_postboot_middleware ⇒ Object
- #setup_preboot_middleware ⇒ Object
- #setup_router ⇒ Object
- #start_message_bus ⇒ Object
Instance Method Details
#load_app_code ⇒ Object
19 20 21 22 |
# File 'lib/volt/volt/server_setup/app.rb', line 19 def load_app_code setup_router require_http_controllers end |
#require_http_controllers ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/volt/volt/server_setup/app.rb', line 37 def require_http_controllers @component_paths.app_folders do |app_folder| # Sort so we get consistent load order across platforms Dir["#{app_folder}/*/controllers/server/*.rb"].each do |ruby_file| # path = ruby_file.gsub(/^#{app_folder}\//, '')[0..-4] # require(path) require(ruby_file) end end end |
#reset_query_pool! ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/volt/volt/server_setup/app.rb', line 75 def reset_query_pool! if RUBY_PLATFORM != 'opal' # The load path isn't setup at the top of app.rb, so we wait to require require 'volt/tasks/live_query/live_query_pool' # Setup LiveQueryPool for the app @database = Volt::DataStore.fetch @live_query_pool = LiveQueryPool.new(@database, self) @channel_live_queries = {} end end |
#run_app_and_initializers ⇒ Object
Load in all .rb files in the initializers folders and the config/app.rb file.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/volt/volt/server_setup/app.rb', line 56 def run_app_and_initializers files = [] # Include the root initializers files += Dir[Volt.root + '/config/initializers/*.rb'] files += Dir[Volt.root + '/config/initializers/server/*.rb'] # Get initializers for each component component_paths.app_folders do |app_folder| files += Dir["#{app_folder}/*/config/initializers/*.rb"] files += Dir["#{app_folder}/*/config/initializers/server/*.rb"] end files.each do |initializer| require(initializer) end end |
#run_config ⇒ Object
This config needs to run earlier than others
49 50 51 52 |
# File 'lib/volt/volt/server_setup/app.rb', line 49 def run_config path = "#{Volt.root}/config/app.rb" require(path) if File.exists?(path) end |
#setup_paths ⇒ Object
13 14 15 16 17 |
# File 'lib/volt/volt/server_setup/app.rb', line 13 def setup_paths # Load component paths @component_paths = ComponentPaths.new(@app_path) @component_paths.require_in_components(self) end |
#setup_postboot_middleware ⇒ Object
33 34 35 |
# File 'lib/volt/volt/server_setup/app.rb', line 33 def setup_postboot_middleware DefaultMiddlewareStack.postboot_setup(self, @middleware) end |
#setup_preboot_middleware ⇒ Object
28 29 30 31 |
# File 'lib/volt/volt/server_setup/app.rb', line 28 def setup_preboot_middleware @middleware = MiddlewareStack.new DefaultMiddlewareStack.preboot_setup(self, @middleware) end |
#setup_router ⇒ Object
24 25 26 |
# File 'lib/volt/volt/server_setup/app.rb', line 24 def setup_router @router = Routes.new end |
#start_message_bus ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/volt/volt/server_setup/app.rb', line 87 def return if ENV['NO_MESSAGE_BUS'] unless RUBY_PLATFORM == 'opal' # Don't run in test env, since you probably only have one set of tests # running at a time, and even if you have multiple, they shouldn't be # updating each other. unless Volt.env.test? # Start the message bus bus_name = Volt.config..try(:bus_name) || 'peer_to_peer' begin = MessageBus.const_get(bus_name.camelize) rescue NameError => e raise "message bus name #{bus_name} was not found, be sure its " + "gem is included in the gemfile." end @message_bus = .new(self) Thread.new do # Handle incoming messages in a new thread @message_bus.subscribe('volt_collection_update') do |collection_name| # update a collection, don't resend since we're coming from # the message bus. live_query_pool.updated_collection(collection_name, nil, true) end end end end end |