How to break Rails5 web and actioncable server [to make them work as separate processes]

I currently have web servers and websocket servers running in the same process. My question is, how can I start a web server without an actioncable server, but still be able to send messages to actioncable server clients in a separate process?

In Rails5 beta, in order to use the action cable, I did this mount ActionCable.server => '/cable'and just deleting this line, I was able to achieve exactly what I wanted. But now it is mounted automatically ...

I tried the "-C" command line option with no luck.

+4
source share
1 answer

1) config/application.rb "/" - :

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"

2) config/application.rb "action_cable/engine" - .

3) app/assets/javascripts/cable.js.

4) app/assets/javascripts/channels.

5) app/channels.

6) config/cable.yml.

7) config/environments/production.rb

# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [   'http://example.com', /http:\/\/example.*/ ]

8) Gemfile remove:

# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'

5,

rails new my-app-name --skip-action-cable
-2

Source: https://habr.com/ru/post/1651275/


All Articles