当我启动 Rails 服务器时自动运行 Faye 服务器 [英] Autorun the Faye server when I start the Rails server

查看:45
本文介绍了当我启动 Rails 服务器时自动运行 Faye 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前让 Faye 使用我的 Rails 3.0.9 应用程序.但是,我在终端中打开了两个单独的选项卡.一种用于 Faye 服务器,一种用于 Rails 服务器.如何在 Rails 启动时集成它们并自动运行 Faye 服务器?

I currently have Faye working with my Rails 3.0.9 application. However I have two separate tabs open in my terminal. One for the Faye server, and one for the Rails server. How can I integrate them and automatically run the Faye server when Rails starts up?

要启动 Faye 服务器,我正在运行:

To start the Faye Server, I am running:

rackup faye.ru -s thin -E production

faye.ru

require 'faye'
faye_server = Faye::RackAdapter.new(:mount => '/faye')
run faye_server

如果您需要更多信息,请告诉我.

Please let me know if you need any more information.

推荐答案

只需创建一个包含以下内容的初始化程序:

Simply create an initializer containing:

Thread.new do
  system("rackup faye.ru -s thin -E production")
end

<小时>

更好的选择:


Better option:

使用https://github.com/FooBarWidget/daemon_controller

这篇关于当我启动 Rails 服务器时自动运行 Faye 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆