Autorun the Faye server when I start the Rails server

ardavis picture ardavis · Jun 21, 2011 · Viewed 8.6k times · Source

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?

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.

Answer

apneadiving picture apneadiving · Jun 21, 2011

Simply create an initializer containing:

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

Better option:

Use https://github.com/FooBarWidget/daemon_controller