Merge branch '2640-folder-api'
[arvados.git] / services / api / config / initializers / eventbus.rb
index a065632e39386c11e5c8bd4741354d73484e988e..7da8ade701050822c8bc8c93c71e8b44ae77b65c 100644 (file)
@@ -1,5 +1,18 @@
 require 'eventbus'
 
 Server::Application.configure do
-  config.middleware.insert_before ActionDispatch::Static, RackSocket, {:handler => EventBus}
+  # Enables websockets if ARVADOS_WEBSOCKETS is defined with any value.  If
+  # ARVADOS_WEBSOCKETS=ws-only, server will only accept websocket connections
+  # and return an error response for all other requests.
+  if ENV['ARVADOS_WEBSOCKETS']
+    config.middleware.insert_after ArvadosApiToken, RackSocket, {
+      :handler => EventBus,
+      :mount => "/websocket",
+      :websocket_only => (ENV['ARVADOS_WEBSOCKETS'] == "ws-only")
+    }
+  end
+
+  # Define websocket_address configuration option, can be overridden in config files.
+  # See application.yml.example for details.
+  config.websocket_address = nil
 end