Skip to content

Commit

Permalink
chore: update anycable configs
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Nov 7, 2019
1 parent d6cf389 commit c46fdf7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 37 deletions.
52 changes: 21 additions & 31 deletions config/anycable.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
# gRPC server settings, anycable grpc server will listen
# websocket server at given host:port, usually Anycable server runs locally to ws server
# MUST BE in sync with ws-server setting -rpc=0.0.0.0:50051
# rpc_host: "localhost:50051"

# redis url
# MUST BE in sync with ws-server setting -redis=redis://localhost:6379/5
# REM: Redis PubSub system doesn't use the database part of URI
# redis_url: "redis://localhost:6379/5"

# redis_sentinels:
# - { host: 'localhost', port: 26379 }
# - { host: 'redis-1-2', port: 26379 }
# - { host: 'redis-1-3', port: 26379 }

# anycable use single pubsub queue, this is queue name
# MUST BE in sync with ws-server setting -redis_channel=__anycable__
# redis_channel: "__anycable__",

#---------- ENVIRONMENT VARIABLES ----------
# since Anycable config based on anyway_config (https://github.com/palkan/anyway_config), all Anycable settings,
# can be set or overridden through corresponding Environment variable.
# Ex: rpc_host is overridden by ANYCABLE_RPC_HOST, redis_url by ANYCABLE_REDIS_URL e.t.c Look in anyway_config for more details

# This file contains per-environment settings for AnyCable.
#
# Since AnyCable config is based on anyway_config (https://github.com/palkan/anyway_config), all AnyCable settings
# can be set or overridden through the corresponding environment variables.
# E.g., `rpc_host` is overridden by ANYCABLE_RPC_HOST, `debug` by ANYCABLE_DEBUG etc.
#
# Note that AnyCable recognizes REDIS_URL env variable for Redis pub/sub adapter. If you want to
# use another Redis instance for AnyCable, provide ANYCABLE_REDIS_URL variable.
#
# Read more about AnyCable configuration here: https://docs.anycable.io/#/ruby/configuration
#
default: &default
rpc_host: <%= ENV.fetch("ANYCABLE_RPC_HOST", "localhost:50051") %>
# Turn on/off access logs ("Started..." and "Finished...")
access_logs_disabled: false
# This is the host and the port to run AnyCable RPC server on.
# You must configure your WebSocket server to connect to it, e.g.:
# $ anycable-go --rpc-host="<rpc hostname>:50051"
rpc_host: "127.0.0.1:50051"
# Whether to enable gRPC level logging or not
log_grpc: false
log_file: nil
debug: false # Shortcut to enable GRPC logging and debug level
log_level: info
# Use the same channel name for WebSocket server, e.g.:
# $ anycable-go --redis-channel="__anycable__"
redis_channel: "__anycable__"
redis_sentinels: []

development:
<<: *default
redis_url: <%= ENV.fetch("REDIS_URL", "redis://localhost:6379/2") %>
redis_url: "redis://localhost:6379/1"

production:
<<: *default
redis_url: <%= ENV.fetch("REDIS_URL", "redis://localhost:6379/1") %>
5 changes: 3 additions & 2 deletions config/cable.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# List of available adapters: async, any_cable
# Make it possible to switch adapters by passing the CABLE_ADAPTER env variable.
# For example, you can use it fallback to the standard Action Cable in staging/review
# environments (by setting `CABLE_ADAPTER=redis`).
development:
adapter: <%= ENV.fetch("CABLE_ADAPTER", "any_cable") %>

Expand All @@ -7,4 +9,3 @@ test:

production:
adapter: <%= ENV.fetch("CABLE_ADAPTER", "any_cable") %>
channel_prefix: evil_chat_production
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker

# Specify AnyCable WebSocket server URL to make JS client connect to it
# Specify AnyCable WebSocket server URL to use by JS client
config.action_cable.url = ENV.fetch("CABLE_URL", "ws://localhost:3334/cable").presence
end
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# Specify AnyCable WebSocket server URL to make JS client connect to it
# Specify AnyCable WebSocket server URL to use by JS client
config.action_cable.url = ENV["CABLE_URL"].presence
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]

Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ services:
EDITOR: vim
RAILS_ENV: ${RAILS_ENV:-development}
DATABASE_URL: postgres://postgres:postgres@postgres:5432
REDIS_URL: redis://redis:6379/
REDIS_URL: redis://redis:6379/0
ANYCABLE_REDIS_URL: redis://redis:6379/0
ANYCABLE_RPC_HOST: 0.0.0.0:50051
WEBPACKER_DEV_SERVER_HOST: webpacker
DISABLE_SPRING: 1
depends_on:
Expand Down Expand Up @@ -79,7 +81,7 @@ services:
- '3334:3334'
environment:
PORT: 3334
REDIS_URL: redis://redis:6379/0
ANYCABLE_REDIS_URL: redis://redis:6379/0
ANYCABLE_RPC_HOST: anycable-rpc:50051
depends_on:
- anycable-rpc
Expand Down

0 comments on commit c46fdf7

Please sign in to comment.