DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Mongrel And Apache Fun With Capistrano 2.0

09.07.2007
| 8071 views |
  • submit to reddit
        I got the Mongrel recipes from somewhere else -- I sadly don't remember where -- and modified them a bit.

namespace :deploy do
  namespace :mongrel do
    [ :stop, :start, :restart ].each do |t|
      desc "#{t.to_s.capitalize} the mongrel appserver"
      task t, :roles => :app do
        run "mongrel_rails cluster::#{t.to_s} --clean -C #{mongrel_conf}"
      end
    end
  end
  
  namespace :apache do
    desc "Start Apache"
    task :start, :roles => :web do
      sudo "/etc/init.d/httpd start > /dev/null"
    end

    desc "Stop Apache"
    task :stop, :roles => :web do
      sudo "/etc/init.d/httpd stop > /dev/null"
    end

    desc "Restart Apache"
    task :restart, :roles => :web do
      sudo "/etc/init.d/httpd restart > /dev/null"
    end
  end

  desc "Custom restart task for mongrel cluster"
  task :restart do
    deploy.mongrel.restart
    deploy.apache.restart
  end

  desc "Custom start task for mongrel cluster"
  task :start, :roles => :app do
    deploy.mongrel.start
    deploy.apache.start
  end

  desc "Custom stop task for mongrel cluster"
  task :stop, :roles => :app do
    deploy.apache.stop
    deploy.mongrel.stop
  end

end