Usando gem de sincronização de trilhos com Faye e Thin no modo de produção no Heroku
Estou tentando configurar a gema 'sync' para permitir atualizações em tempo real no meu aplicativo rails. Isso usa o Faye como um serviço de push em tempo real e fino como o servidor da web.
Eu sou muito novo nisso. Portanto, qualquer conselho é apreciado.
Eu tenho isso funcionando no meu servidor local, mas não sei como fazê-lo funcionar no modo de produção no heroku. Esta é a minha configuração:
No meu gemfile:
gem 'faye'
gem 'thin', require: false
gem 'sync'
Na minha pasta raiz, tenho um arquivo sync.ru
require "bundler/setup"
require "yaml"
require "faye"
require "sync"
Faye::WebSocket.load_adapter 'thin'
Sync.load_config(
File.expand_path("../config/sync.yml", __FILE__),
ENV["RAILS_ENV"] || "development"
)
run Sync.pubsub_app
Na minha config / sync.yml
# Faye
development:
server: "http://localhost:9292/faye"
adapter_javascript_url: "http://localhost:9292/faye/faye.js"
auth_token: DEVELOPMENT_SECRET_TOKEN
adapter: "Faye"
async: true
production:
server: "http://my_app_name.com/faye"
adapter_javascript_url: "http://localhost:9292/faye/faye.js"
adapter: "Faye"
auth_token: "1b7329869f09aa98499258dfe9c377cdd2c89c05b99069176445942575348da0"
async: true
No meu servidor local, eu simplesmente corro:
rackup sync.ru -E production
Isso inicia o servidor da Web thin e as atualizações em tempo real funcionam no meu aplicativo.
Como posso fazer isso funcionar no Heroku?
Tentei adicionar o seguinte ao meu procfile (não faço ideia se é a coisa certa a fazer)
web: bundle exec thin -p $PORT -e $RACK_ENV -R sync.ru start
Quando tento carregar meu aplicativo, meu navegador exibe o seguinte texto:
Sure you're not looking for /faye ?
E o meu log heroku diz:
app[web.1]: Starting process with command 'bundle exec thin -p 57204 -e production -R sync.ru start'
app[web.1]: Listening on 0.0.0.0:57204
app[web.1]: Maximum connections set to 1024
app[web.1]: Thin web server (v.1.6.3 codename Protein Powder)
heroku[web.1]: State changed from up to starting
heroku[web.1]: Process exited with status 137
heroku[web.1]: Process exited with status 0
heroku[web.1]: Starting process with command 'rackup sync.ru -E production'
heroku[web.1]: Stopping all processes with SIGTERM
heroku[web.1]: Process exited with status 137
heroku[web.1]: Stopping process with SIGKILL
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: State changed from crashed to start
heroku[web.1]: Error R10 (Boot timeout) Web process failed to bind to $PORT within 60 sec of launch