Rails + Faye + Apache: Moving Faye from thin to passenger

Deployment is currently working with our main application on Passenger and Faye on Thin. But I have some problems that go from this setting to Faye using a passenger.

Here it is suggested ( https://github.com/faye/faye-websocket-ruby ) that I can run Faye on a stand-alone passenger and start the specified server using this command

passenger start -p 9292

However, this does not even work locally. He first returns this error, stating that he cannot find faye.js in

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__

Error in this

Failed to load resource: the server responded with a status of 404 (Not Found) 

When you change the browser to the specified location, it says

no route matches [GET] "/faye"

Looking at the passenger logs, it seems that he first encountered this error

Started GET "/faye" for 127.0.0.1 at 2014-05-09 10:04:23 -0700

ActionController::RoutingError (No route matches [GET] "/faye"):

and then run this

Started OPTIONS "/faye" for 127.0.0.1 at 2014-05-09 10:04:58 -0700

ActionController::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

, , ... ? 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)

Edit:

faye-rails gem, (. ).

config.middleware.delete Rack::Lock

( )

faye-rails can't work when Rack::Lock is enabled, as it will cause
a 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)
+4
2

faye-rails gemfile, :

'faye-rails', '~> 2.0.0'

Update:

, , application.rb

config.middleware.delete Rack::Lock

, .

+1

, faye.ru Thin. Phusion Passenger config.ru . , , faye.ru config.ru?

0

Source: https://habr.com/ru/post/1539957/


All Articles