From d0b2bf5d9140bf233039f145073fab455058b0ef Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Thu, 25 Jun 2020 22:12:34 +0300 Subject: [PATCH] Reconfigure AnyCable to use HTTP adapter and locally installed anycable-go --- .github/workflows/system_test.yml | 5 ++--- Procfile.dev | 4 ++++ config/anycable.yml | 9 +++++++-- config/environments/test.rb | 2 +- spec/system/support/anycable_setup.rb | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 Procfile.dev diff --git a/.github/workflows/system_test.yml b/.github/workflows/system_test.yml index aa09f6f..36b591d 100644 --- a/.github/workflows/system_test.yml +++ b/.github/workflows/system_test.yml @@ -52,8 +52,7 @@ jobs: - name: Run RSpec run: | bundle exec rails db:prepare - bundle exec rails g anycable:download --bin-path=./bin + sudo bundle exec rails g anycable:download --bin-path=./bin bundle exec rails webpacker:compile - ./bin/anycable-go --host "0.0.0.0" & - export CABLE_URL="ws://$(hostname):8080/cable" + sudo cp ./bin/anycable-go /usr/local/bin/ bundle exec rspec --tag type:system diff --git a/Procfile.dev b/Procfile.dev new file mode 100644 index 0000000..7a8dd77 --- /dev/null +++ b/Procfile.dev @@ -0,0 +1,4 @@ +server: bundle exec rails s +assets: bundle exec bin/webpack-dev-server +anycable: bundle exec anycable +ws: anycable-go --port=8080 --broadcast_adapter=http diff --git a/config/anycable.yml b/config/anycable.yml index 0739ce6..a8a5521 100644 --- a/config/anycable.yml +++ b/config/anycable.yml @@ -20,8 +20,8 @@ default: &default rpc_host: "127.0.0.1:50051" # Whether to enable gRPC level logging or not log_grpc: false - # Use Redis to broadcast messages to AnyCable server - broadcast_adapter: redis + # Use HTTP adapter for a quick start (since redis gem is not present in the project) + broadcast_adapter: http # Use the same channel name for WebSocket server, e.g.: # $ anycable-go --redis-channel="__anycable__" redis_channel: "__anycable__" @@ -29,5 +29,10 @@ default: &default development: <<: *default +test: + <<: *default + production: <<: *default + # Use Redis in production + broadcast_adapter: redis diff --git a/config/environments/test.rb b/config/environments/test.rb index 16d633b..ca253ab 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -11,7 +11,7 @@ # Specify AnyCable WebSocket server URL to use by JS client config.after_initialize do - config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL", "ws://localhost:8080/cable") + config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL", "ws://127.0.0.1:8080/cable") end config.action_cable.mount_path = nil diff --git a/spec/system/support/anycable_setup.rb b/spec/system/support/anycable_setup.rb index 9f5a703..3371fcd 100644 --- a/spec/system/support/anycable_setup.rb +++ b/spec/system/support/anycable_setup.rb @@ -10,7 +10,7 @@ require "anycable/cli" cli = AnyCable::CLI.new(embedded: true) - cli.run + cli.run(["--server-command", "anycable-go --broadcast_adapter=http"]) config.after(:suite) do cli&.shutdown