Faye setup in production

好久不见. 提交于 2019-12-10 10:24:38

问题


I've set up Faye on localhost, and works fine.

I'm now trying to deploy it on DigitalOcean VPS, with Cloud66 deployment service. To run the command I use an "after_rails" hook.

rackup $RAILS_STACK_PATH/faye.ru -s thin -E production

This gives me the error:

Error during deployment: Error during after_rails hook: Server: not_specified. Failed to run command: /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- faye (LoadError) from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire' from /var/deploy/anabol/web_head/current/faye.ru:1:in block in <main>' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:ininstance_eval' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in initialize' from /var/deploy/anabol/web_head/current/faye.ru:innew' from /var/deploy/anabol/web_head/current/faye.ru:in <main>' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:49:ineval' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:49:in new_from_string' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:40:inparse_file' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:277:in build_app_and_options_from_config' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:199:inapp' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:314:in wrapped_app' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:250:instart' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/server.rb:141:in start' from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.5.2/bin/rackup:4:in' from /usr/local/bin/rackup:23:in load' from /usr/local/bin/rackup:23:in'

github repo: https://github.com/gwuix2/anabol

Any suggestions what could be the problem? Don't know where to start.


回答1:


I've written up some documentation on how to solve this problem in case anyone else runs into it. You can find it here: http://community.cloud66.com/articles/faye-on-cloud-66

Disclaimer: I work for Cloud 66.




回答2:


Cloud 66 Support solved my problem:

Hi there,

We run faye on our own stack. We actually run it behind thin - and monitor it as a process on the stack. The way we do this is with four files - see their details below:

1) RAILS_ROOT/.cloud66/deploy_hooks.yml

production:
before_rails:
- source: /.cloud66/files/add_thin_and_faye.sh
destination: ~/add_thin_and_faye.sh
target: rails
execute: true
sudo: true
apply_during: build_only
run_on: all_servers

2) RAILS_ROOT/.cloud66/files/add_thin_and_faye.sh

#!/bin/bash
sudo gem install thin --no-ri --no-rdoc
sudo gem install faye --no-ri --no-rdoc

3) RAILS_ROOT/Procfile

faye: thin -R $RAILS_STACK_PATH/faye/config.ru start

4) RAILS_ROOT/faye/config.ru

require 'faye'
faye_server = Faye::RackAdapter.new(:mount => '/your_faye_mount', :timeout => 45)
Faye::WebSocket.load_adapter('thin')
faye_server.listen(<<PUT-YOUR-PORT-HERE>>)

Note that for part 4) the settings will be different based on your requirements of course.

If you follow the setup above, you'll have faye running alongside your stack, and it will be available as a process on your stack.



来源:https://stackoverflow.com/questions/18228665/faye-setup-in-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!