Hello all,

I have three ruby scripts that act as workers for AMQP (rabbitmq). I
have a main ruby script that stops (killall) and then starts them:

script/run_workers:

kill_workers()

puts "Starting workers"

puts system("ruby #{worker_script} 1 &")
puts system("ruby #{worker_script2} 1 &")
puts system("ruby #{worker_script3} 1 &")

The first worker (worker_script), loads the Rails environment upon
start:

require 'rubygems'
require 'mq'

require File.dirname(__FILE__) + '/../config/environment'
require File.dirname(__FILE__) + '/../lib/pidfile'

AMQP.start do
  ...
end

The others just follow the AMQP.start { } pattern.

If I run the script/run_workers locally, *all three are started
successfully and stay resident in memory as expected*. If I ssh into
our production server and do the same, *everything works fine*. The
issue I'm having is starting them through capistrano. Here's what I
did:

deploy.rb:
...
  desc "Kill and start the workers"
  task :workers, :roles => :app do
    run "#{current_release}/script/run_workers"
  end

I do get a "Starting workers" output from the script:

** [out :: staging.xxx.com] Starting workers...

But I when I ssh into the server and check the processes, none of the
workers are resident.

I then tried to add a nohup, as seen in this message (http://www.mail-
archive.com/[email protected]/msg00871.html), like
this:

  desc "Kill and start the workers"
  task :workers, :roles => :app do
    run "nohup #{current_release}/script/run_workers"
  end

Then, strangely enough, worker2 and 3 are started and stay in mem. But
worker1 does not. Worker 1 is the one that loads Rails.

I'm totally lost, I have no idea why worker1 is not being started when
nohup is being used, and why none of them are started when nohup is
not used. Any hints appreciated!

Capistrano v2.5.19
Production server: Ubuntu 9.10
Dev. box: OSX Snow Leopard.
Ruby 1.8.7.

Thanks in advance,

Marcelo.






-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to 
[email protected] For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en

Reply via email to