gpt4 book ai didi

ruby-on-rails - 如何使用 daemon-controller 自动启动 faye?

转载 作者:行者123 更新时间:2023-12-04 06:08:17 31 4
gpt4 key购买 nike

我正在尝试使用 gem daemon_controller 自动运行 faye。
我的类(class)

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

功能 我在 ApplicationController 中使用 before_filter

 def start_faye
fayes = FayeDaemon.new
fayes.start
end

因此 faye 没有运行错误
DaemonController::StartTimeout(守护进程“Faye 服务器”没有及时守护进程。)

当调用 fayes.start 时。

我做错了什么?

最佳答案

我强烈建议你使用 foreman 而不是 deamon_controller,你可以找到很好的介绍 here .只需安装 gem,在您的 rails 根目录中创建“Procfile”。并创建两个作业,一个用于服务器,另一个用于 Faye,它可能如下所示:

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

关于ruby-on-rails - 如何使用 daemon-controller 自动启动 faye?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13720154/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com