Ruby on rails 在Heroku上以生产模式使用rails同步gem与Faye和Thin

Ruby on rails 在Heroku上以生产模式使用rails同步gem与Faye和Thin,ruby-on-rails,heroku,webserver,thin,faye,Ruby On Rails,Heroku,Webserver,Thin,Faye,我正在尝试设置“同步”gem,以便在我的rails应用程序中启用实时更新。它使用Faye作为实时推送服务,使用thin作为Web服务器 我对这个很陌生,所以任何建议都很感激 我在本地服务器上运行此功能,但不知道如何在heroku上使其在生产模式下运行。这是我的设置: 在我的文件中: gem 'faye' gem 'thin', require: false gem 'sync' 在我的根文件夹中,我有一个sync.ru文件 require "bundler/setup" require "ya

我正在尝试设置“同步”gem,以便在我的rails应用程序中启用实时更新。它使用Faye作为实时推送服务,使用thin作为Web服务器

我对这个很陌生,所以任何建议都很感激

我在本地服务器上运行此功能,但不知道如何在heroku上使其在生产模式下运行。这是我的设置:

在我的文件中:

gem 'faye'
gem 'thin', require: false
gem 'sync'
在我的根文件夹中,我有一个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
在my 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
在本地服务器上,我只需运行:

rackup sync.ru -E production
这将启动瘦web服务器并在我的应用程序中进行实时更新

我怎样才能在Heroku上工作

我已尝试将以下内容添加到procfile中(不知道这样做是否正确)

当我尝试加载我的应用程序时,我的浏览器会显示以下文本:

Sure you're not looking for /faye ?
我的heroku日志上写着:

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
我部署了两个heroku应用程序。 一个是用于同步发布/订阅系统的精简服务器,它与您的Procfile一起部署:

# this Procfile contains only the following line.
web:  bundle exec thin -p $PORT -e $RACK_ENV -R sync.ru start
另一个是默认的web服务器,部署时没有Procfile

另外,我将
服务器
适配器_javascript_url
参数设置为指向sync.yml中的精简服务器

production:
  server: "http://xxx-sync.herokuapp.com/faye"
  adapter_javascript_url: "http://xxx-sync.herokuapp.com/faye/faye.js"
  adapter: "Faye"
  auth_token: <=% ENV["SYNC_AUTH_TOKEN"] %>
  async: true
生产:
服务器:“http://xxx-sync.herokuapp.com/faye"
适配器\u javascript\u url:“http://xxx-sync.herokuapp.com/faye/faye.js"
适配器:“费伊”
身份验证令牌:
异步:true
这种方法对我来说可以与HTTP协议一起工作


消息“确定您没有在找/faye?”表明瘦服务器工作正常。

为了让它在登台/生产中发挥作用,我做了一些努力。如果有人不是在heroku上,而是在EC2/rackspace等专用服务器上,请发布我的答案

您需要使用下面的命令启动服务器

RAILS_ENV=production bundle exec rackup sync.ru -E production

在服务器设置中是http还是https?
RAILS_ENV=production bundle exec rackup sync.ru -E production