2012-12-05 76 views
3

我想使用gem daemon_controller自动运行faye。
我的班级如何使用守护进程控制器自动启动faye?

require "daemon_controller" 
class FayeDaemon 
def initialize 
    @controller = DaemonController.new(
     :identifier => 'Faye server', 
     :start_command => "rackup faye.ru -s thin -E production", 
     :ping_command => [:tcp , 'localhost', 9292], 
     :log_file  => 'log/faye.log', 
     :pid_file  => 'tmp/pids/faye.pid', 
     :start_timeout => 5 
    ) 
end  

    def start 
    @controller.start 
    end 
end 

功能我为的before_filter使用的ApplicationController

def start_faye 
fayes = FayeDaemon.new 
fayes.start 
end 

结果王菲不会错误
DaemonController :: StartTimeout(守护进程“王菲服务器上运行'没有及时守护神。)

当fayes.start被调用。

我做错了什么?

回答

2

我强烈建议你使用工头代替deamon_controller,你可以找到很好的介绍here。只需安装gem,在rails根目录下创建'Procfile'。并创造两份工作,一个用于服务器和其他的王菲,也可能是这样的:

web: bundle exec rails server webrick -b 127.0.0.1 -p 3000 -e development 
faye: bundle exec rackup faye.ru -s thin -E production 

foreman start 
开始工头