#3 ActionCable on Production
SummaryTaking a look at ActionCable and switching from Puma to Thin. On server reboot, spin up the ActionCable service.
streaming rails websockets 6:13
Whenever Gem - https://github.com/javan/whenever
ActionCable Examples - https://github.com/rails/actioncable-examples
gem 'actioncable', github: 'rails/actioncable' gem 'thin' gem 'whenever', :require => false
One thing that I neglected to mention is that you do need to write to your crontab once you have made your changes to the `schedule.rb` file. You can do this by running `whenever -w` in your application directory on the production machine.
touch bin/cable chmod +x bin/cable
Change out the `puma` server startup script to `thin`
# /bin/bash bundle exec thin start -C config/cable.yml
Be sure to add the `thin` adapter to the Faye Websocket.
require ::File.expand_path('../../config/environment', __FILE__) Rails.application.eager_load! require 'action_cable/process/logging' Faye::WebSocket.load_adapter('thin') run ActionCable.server
Create your `cable.yml` file and put the appropriate settings for your server.
--- chdir: /home/user/drifting_ruby environment: production port: 8443 timeout: 30 log: log/thin.log pid: tmp/pids/thin.pid max_conns: 8192 max_persistent_conns: 8192 require:  wait: 30 threadpool_size: 4 servers: 1 daemonize: true ssl: true ssl-disable-verify: true ssl_key_file: ssl/ssl.key ssl_cert_file: ssl/ssl.crt rackup: cable/config.ru
Some notes for installing Redis. These instructions work on Ubuntu 14.04, but may work on other Debian-based distributions.
sudo apt-get update sudo apt-get install build-essential sudo apt-get install tcl8.5 wget http://download.redis.io/releases/redis-stable.tar.gz tar xzf redis-stable.tar.gz cd redis-stable make make test sudo make install cd utils sudo ./install_server.sh sudo service redis_6379 start sudo service redis_6379 stop
there were a term for a passenger in hand and learn what they wouldn't have a look at the actual cable examples and the roses organizational get out all we're going to do is weren't too good to get the whom a web server the workplace away the dead now so yeah you can set the set to sport has to sell certificates or also going to take a look at how old the red us is configured as well as by making sure that that it started out every time you read the groundwork asian and also your server so today we're pouring to look at those you want so let's dive in to set the person we're going to screw the get out rico them we're going to our quality on screen instructions to set up the development of iran so here's how i installed runners there's i eat and start up the servers so gary have everything cool down and i'll start the rules are lurking i walked i've been slashed able to start optic cables are men are sir not be read as server and blood test and as we didn't see that it does work already right out of box with all those services running so that we have our two users among earners be edgy here the song and snoop being going to war like messaging huh where we see a popping out and silly or both sides of this works great in your development of our right where are you are most likely going to serve your application over as a cell that it has in trouble getting it running with whom are so today we're in a look at how we can set this up with certain server so that we can use leave our asses so certificates and so was wearing clothes east and we are going to go into our application and the person that you want to use on your job i'll actually going to get rid of whom i knew of places with the ten bullets are they sure you're a bottle and i'm so years then card next you're going to go under the sea cable can take are you then we're not a change too much here but the one thing that we do have to act as we have said let the the web socket know that we're running the adapter then sell all users wow my five year just couldn't eat any what socket and then but after him they chased us by the heads and that should be able to borrow start that up i've next were no we will go into the current directory the non or cable network like to replace those words living out the promo what server or or twenty eight eighty there were just born to run that so we are running thin air we're putting a typical i'll fake you'll got a gamble so was going create our topic while so that we ordered come begging a man we will create a new file the airwaves can recall those cable guy and yellow but then you can right now we get to the shadows this here who's so you are basically it's like to direct trade they are born to have it running or so this is the root of application then you have your apartment support the war to ride on that your changing this to something other than what the rich all those rules running on a journey your change web socket wing singer jobs with files as well however you can slide anything in the u or a timeout year are a lot while or you were no longer sue by the next family connections you'd read the whole sars number servers they met matt damon are using it so you will i'll just run in the background but as is so true if he had trouble with either your asses of certificates again slide disabled true ah false you're just make sure there is water probably then you reference to a drug free when he addresses else read it gets installed it finally we're than kong de yah but cable cutters are you for starting up the application so once we get ah those changes lately should be done now when the things that we want to do is whenever this service power the server gets repeated we wanna make sure that the action cable is on actually started and do what the easiest ways to do this as you get ready to learn whenever i and by adding this show whenever and you check the documentation for the out on piles for the odd man suit generated bible would you do is go under the big four is greedy when file not clear was called those schedule doherty i'd he and then he came out a great ask it and started or or you can simply do not hot i'll read as says okay legs arms look he thinks he'll live example of this one healing tv could do ruby website under the tech sector you type a message us and then automatically broadcast and everyone loses right to the channel so this is a working example of actual fuel their production running began web server or an actual cable over s s l web sockets as well as reading writers as a background so