All Lessons / How to Deploy ActionCable and Rails 5 To Production

How to Deploy ActionCable and Rails 5 To Production

#103 ยท February 4, 2016

Your Teacher | Chris Oliver

Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.

About This Episode

Learn how to deploy ActionCable and Rails 5 with Passenger

Notes

Resources

# If you don't have redis server already installed, 
# make sure to install that if you choose to use that as the backend
sudo apt-get install redis-server
# config/cable.yml
production:
  url: redis://localhost:6379

local: &local
  url: redis://localhost:6379

development: *local
test: *local
# config/routes.rb
mount ActionCable.server => "/cable"
# app/assets/javascripts/channels/index.coffee
App.cable = ActionCable.createConsumer("/cable")
# config/environments/production
config.action_cable.allowed_request_origins = ["https://gorails.com"]
# /etc/nginx/sites-enabled/default
server {
  listen 80;
  server_name gorails.com;

  passenger_enabled on;
  rails_env production;
  root /home/deploy/gorails/current/public;

  location /cable {
    passenger_app_group_name gorails_websocket;
    passenger_force_max_concurrent_requests_per_process 0;
  }

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root html;
  }
}

Discussion

Loading...
logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.