Peter Swank
Peter Swank

Reputation: 31

How to start faye automatically using daemon-controller?

I am trying to run faye automatically using gem daemon_controller.
My 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

Function I use as before_filter in ApplicationController

 def start_faye
 fayes = FayeDaemon.new
 fayes.start
 end

as a result faye doesn't run with error
DaemonController::StartTimeout (Daemon 'Faye server' didn't daemonize in time.)

when fayes.start is called.

what i did wrong?

Upvotes: 3

Views: 715

Answers (1)

Octopussy
Octopussy

Reputation: 142

I highly recommend you to use foreman instead of deamon_controller, you can find good introduction here. Just install gem, create 'Procfile' in your rails root directory. and create two jobs, one for server and other for Faye, it could look like this:

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

and start foreman with

foreman start

Upvotes: 2

Related Questions