它建议在这里(https://github.com/faye/faye-websocket-ruby)我可以在Passenger Standalone上运行Faye并使用此命令启动所述服务器
passenger start -p 9292
但是,这甚至不能在本地工作.首先它返回此错误,指出它无法找到faye.Js
http://localhost:9292/faye?message=%5B%7B%22channel%22%3A%22%2FMeta%2Fhandshake%22%2C%22version%22%3A%221.0%22%2C%22supportedConnectionTypes%22%3A%5B%22callback-polling%22%5D%2C%22ID%22%3A%221%22%7D%5D&Jsonp=__Jsonp1__
错误就是这个
Failed to load resource: the server responded with a status of 404 (Not Found)
当您将浏览器更改为指定位置时,它会显示
no route matches [GET] "/faye"
看着乘客日志,它似乎首先遇到了这个错误
Started GET "/faye" for 127.0.0.1 at 2014-05-09 10:04:23 -0700ActionController::RoutingError (No route matches [GET] "/faye"):
然后遇到这个
Started OPTIONS "/faye" for 127.0.0.1 at 2014-05-09 10:04:58 -0700ActionController::RoutingError (No route matches [OPTIONS] "/faye"):
使用Thin运行时,我使用以下命令启动服务器
bundle exec rackup faye.ru -s thin --daemonize -E production
乘客开始尝试和瘦身之间有一些差异,但最大的一个是faye.ru永远不会运行.我的faye.ru是基本的
require 'faye'faye_server = Faye::RackAdapter.new(:mount => '/faye',:timeout => 45)Faye::WebSocket.load_adapter('thin')run faye_server
把它切换到Passenger,我知道我需要删除第三行…但那又怎么样?当我直接将其添加到我的config.ru文件中时,faye服务器最终接管了整个应用程序,这绝对不是我的目标.我想也许把它放在初始化器中会起作用,但是我遇到了以下错误:
undefined method `run' for main:Object (NoMethodError)
我假设是因为这不是.ru文件而是.rb文件.
无论如何,我发现自己很困惑,我绝对会欣赏任何提示/方向.
编辑:
该网站(http://rubydoc.org/github/jamesotron/faye-rails/frames)声明
If you want to run faye-rails on passenger,make sure you are using passenger 4.0 standalone or passenger 4.0 on Nginx 1.4+ for Nginx with websocket support. Passenger on apache is not supported. Because passenger uses a multi-process model,you must use the faye redis backend. Add gem 'faye-redis' to your Gemfile and configure your routes like this:config.mIDdleware.use FayeRails::MIDdleware,mount: '/faye',:timeout => 25,server: 'passenger',engine: {type: Faye::Redis,host: 'localhost'}
但是我已经尝试将相关代码添加到我的application.rb中,其中我有几个配置命令
module App class Application < Rails::Application
但只是在下面添加(我所有其他配置.无论是什么)上面建议的代码导致此错误
uninitialized constant App::Application::FayeRails (nameError)
编辑:
添加了faye-rails gem,因为我是个白痴(见评论).这也需要添加
config.mIDdleware.delete Rack::Lock
因为(控制台输出)
faye-rails can't work when Rack::Lock is enabled,as it will causea deadlock on every request.
但是,现在我遇到了这个错误
/Users/WEF6/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/dependencIEs.rb:229:in `require': cannot load such file -- passenger (LoadError)
这必须与我在本文中概述的一些变化相关,正如我上面概述的那样,我在本地成功乘客启动后如何收到错误.现在运行乘客服务器会抛出以下错误
Could not spawn process for group location#default: An error occured while starting up the preloader. in 'voID Passenger::ApplicationPool2::SmartSpawner::handleErrorResponse(Passenger::ApplicationPool2::SmartSpawner::StartupDetails &)' (SmartSpawner.h:455) in 'string Passenger::ApplicationPool2::SmartSpawner::negotiatePreloaderStartup(Passenger::ApplicationPool2::SmartSpawner::StartupDetails &)' (SmartSpawner.h:566) in 'voID Passenger::ApplicationPool2::SmartSpawner::startPreloader()' (SmartSpawner.h:206) in 'virtual Processptr Passenger::ApplicationPool2::SmartSpawner::spawn(const Passenger::ApplicationPool2::Options &)' (SmartSpawner.h:752) in 'voID Passenger::ApplicationPool2::Group::spawnThreadRealMain(const SpawnerPtr &,const Passenger::ApplicationPool2::Options &,unsigned int)' (Implementation.cpp:804)[ 2014-05-09 12:15:15.1055 71107/0x10c9ce000 agents/HelperAgent/RequestHandler.h:2222 ]: [ClIEnt 21] Cannot checkout session.Error page:cannot load such file -- passenger (LoadError)解决方法 您必须在gemfile中声明faye-rails gem,包括以下行:
'faye-rails','~> 2.0.0'
更新:
我认为您可以解决机架锁定问题,在您的application.rb中添加以下行
config.mIDdleware.delete Rack::Lock
我希望这可以帮助你.
总结以上是内存溢出为你收集整理的ruby-on-rails – Rails Faye Apache:将Faye从瘦身转移到乘客全部内容,希望文章能够帮你解决ruby-on-rails – Rails Faye Apache:将Faye从瘦身转移到乘客所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)