Sha256: 61fde4d31557388edcf962a4ae6185884e6970a43cf254c7fcc96bf04e9606ff

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

# Create init script
namespace :mongrel_cluster do
  
  after "mongrel_cluster:setup", "mongrel_cluster:setup_monit"
    
  desc "Create mongrel cluster"
  task :setup do 
    run "mkdir -p #{shared_path}/config"
    
    # Mongrel cluster config needs its own config directory
    mongrel_config_path = "#{shared_path}/config/mongrel" 
    run "mkdir -p #{mongrel_config_path}"
    
    pid_path = "#{shared_path}/pids"
    
    put load_template("mongrel/mongrel_cluster.initd.erb", binding), "/tmp/mongrel_cluster_#{application}.initd"    
    put load_template("mongrel/mongrel_cluster.yml.erb", binding), "#{mongrel_config_path}/mongrel_cluster.yml"
    
    # Setup the mongrel_cluster init script
    sudo "install -o root /tmp/mongrel_cluster_#{application}.initd /etc/init.d/mongrel_cluster_#{application}"
        
    sudo "/sbin/chkconfig --level 345 mongrel_cluster_#{application} on"
  end
  
  desc "Create monit configuration for mongrel cluster"
  task :setup_monit do
    
    # see http://www.igvita.com/2006/11/07/monit-makes-mongrel-play-nice/
    
    # TODO: For depends on memcached setting
    # see http://blog.labratz.net/articles/2007/5/1/monit-for-your-uptime 
    
    processes = []
    ports = (0...mongrel_size).collect { |i| mongrel_port + i }
    ports.each do |port|
      
      pid_path = "#{shared_path}/pids/mongrel.#{port}.pid"
      start_options = "-d -e production -a 127.0.0.1 -c #{current_path} --user #{user} --group #{user} -p #{port} -P #{pid_path} -l log/mongrel.#{port}.log"
      stop_options = "-p #{port} -P #{pid_path}"
      
      processes << { :port => port, :start_options => start_options, :stop_options => stop_options, :name => "/usr/bin/mongrel_rails", :pid_path => pid_path }
    end
    
    put load_template("mongrel/mongrel_cluster.monitrc.erb", binding), "/tmp/mongrel_cluster_#{application}.monitrc"
    
    sudo "install -o root /tmp/mongrel_cluster_#{application}.monitrc /etc/monit/mongrel_cluster_#{application}.monitrc"
  end
    
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capigen-0.1.1 recipes/mongrel_cluster.rb
capigen-0.1.2 lib/recipes/mongrel_cluster.rb
capigen-0.1.3 lib/recipes/mongrel_cluster.rb