[Mongrel] mongrel cluster restart with capistrano fails but manually works

Michael Steinfeld mikeisgreat at gmail.com
Tue Apr 3 12:23:43 EDT 2007


Hi all,

I am out of my head here...

I have a 3 node cluster with 10 mongrels running on each. When I
deploy, I break all the mongrels every time. I have tried just about
everything. I can restart my mongrels without a hitch manually, it's
only when I use cap deploy. Maybe I am missing something here... so if
I can get some help it would be appreciated. The errors are the
typical mongrel pid errors, I can paste them if need be.

I have mongrel_cluster.yml sym linked from
/{current_path}/config/mongrel_cluster.yml to
/etc/mongrel_cluster/mongrel_cluster.yml

cwd: /home/app/current
port: "8000"
address: 127.0.0.1
pid_file: log/mongrel.pid
environment: production
servers: 10



here is a snippet of  my deploy.rb

<snip>

require 'mongrel_cluster/recipes'
require 'capistrano'

# below snipped for brevity
role :web
role :app

...


# restart mongrel with /etc/init.d/mongrel_cluster restart
desc "Restart the web server"
task :restart, :roles => :app do
  begin
    run "sudo /etc/init.d/mongrel_cluster stop"
    run "sleep 5"
    run "sudo /etc/init.d/mongrel_cluster start"
end

...
# couple of tasks to chown some files and directories
desc "Only app servers get this applied to them post-deployment"
task :after_app_deploy, :roles=>:app do
  sudo "chown -PRf foo:foo       #{deploy_to}/current/"
  sudo "chown -PRf foo:foo       #{deploy_to}/releases/"
  sudo "chmod -Rf 755                     #{deploy_to}/releases/"
  sudo "chmod -Rf 750                     #{deploy_to}/current/public/"
end

desc "Apache restarter"
task :kick_apache, :roles=>:web do
  sudo "/usr/local/apache/bin/apachectl restart"
end


Now, mongrel gets restarted even if I don't use the above when I
restart when I run deploy.. but I don't see where I can change that or
if that is in fact causing the problem.

for whatever reason, mongrels never start on 8000 - 8004, but do start
from 8005 - 8009, so I am thinking something in the cap script. I did
migrate recently from lighty+fastcgi to apache+mongrel
and I have 10 mongrels per machine on ports 8000 - 8009. I was
thinking that dispatch was screwing up ports 8000-04 somehow.. (
totally guessing )

I was thinking about writing a task similar to below... but I think it
is overkill.

desc "Kill all the pids in case there are some zombies and remove the
.pid files"
task :before_before_deploy, roles => :app do
  begin
    run "sudo kill -9 `ps -ef | grep mongrel | egrep -v grep | awk
'{print $2}'`"
    run "cd /home/user/app/log && sudo rm -rf *.pid"
  end

task :after_after_deploy, roles => :app do
  begin
    " sudo /etc/init.d/mongrel_cluster start"
  end

</snip>


Hopefully someone can see something that I don't.
Thanks for your time

-- 
-mike


More information about the Mongrel-users mailing list