[ANN] mongrel_cluster-0.1.1: the bird dog (capistrano suppor

Hey y’all:

mongrel_cluster provides management tools for running Mongrel behind
a reverse-proxy/load balancer. It is an extraction from Rails
Machine, a deployment service and Ruby library that simplifies Rails
application deployment. This release fixes bugs and adds a Capistrano
task library.

Changes:
-changed pid file format to include port
-only write configuration options that are explicitly specified or
required.
-removed some validation rules and delegate to mongrel_rails.
-added Capistrano task library.

Please rerun mongrel_rails cluster::configure to ensure smooth
operation.

Capistrano Recipe

Add to config/deploy.rb:
require ‘mongrel_cluster/recipes’

Example usage:
cap -a configure_mongrel_cluster

Variables
mongrel_servers: Number of Mongrel servers to start.
mongrel_port: Starting port to bind to.
mongrel_address: Address to bind to.
mongrel_environment: Rails environment to run as.
mongrel_config: Path to config file.
use_sudo: Whether or not tasks that can use sudo, ought to use sudo.
Capistrano defaults to true.

Tasks (performed on :app role)
configure_mongrel_cluster: Configure the cluster with variables. Uses
sudo if use_sudo is true.
start_mongrel_cluster: Start Mongrel processes on the app server.
Uses sudo if use_sudo is true.
stop_mongrel_cluster: Stop the Mongrel processes on the app server.
Uses sudo if use_sudo is true.
restart_mongrel_cluster: Restart the Mongrel processes on the app
server. Uses sudo if use_sudo is true.
restart: Calls restart_mongrel_cluster to allow Mongrel to be used
with the standard Capistrano deploy task.
spinner: Calls start_mongrel_cluster to allow Mongrel to be used with
the standard Capistrano cold_deploy task.

Good luck and let me know how it works for ya!

Thanks,
Bradley Taylor

Rails Machine
Simplified web application deployment
http://railsmachine.com

Uff, I got lost. I had mongrel_cluster 0.1working fine, even with
capistrano
(my own hack). Then came mongrel_cluster 0.1.1 and I tried to set it
up,
but somehow I messed up things and nothing worked anymore. So here what
I
did:

on production machine: (debian linux, rails 1.1)

  • installing mongrel_cluster 0.1.1

on development machine**: (windows XP, raills 1.1)

  • inststalling mongrel_cluster 0.1.1

  • recreating config file: mongrel_rails cluster::configure

  • modifying configfile manually to make it look like this: (will be more
    the
    one server later)


num-procs: 1024
docroot: public
timeout: 120
cwd: /home/me/sites/myapp/current
log_file: log/mongrel.log
port: 3000
config_script:
debug: false
environment: production
servers: 1
pid_file: log/mongrel.pid
address: 0.0.0.0
mime_map:

  • deploy.rb: commented out my old restart and spinner tasks and added:
    require ‘mongrel_cluster/recipes’

  • deployment: rake deploy (fails because config file is at:
    /home/me/sites/myapp/current/config/mongrel_cluster.yml)

    executing “mongrel_rails cluster::restart -C
    /home/me/sites/myapp/config/mongrel_cluster.yml”

then I thought I could give “cap -a configure_mongrel_cluster” a try,
hoping
it would put things into the right order, but I got this:

** [out :: xx.xx.xx.xx] !!! Path to log file not valid: log/mongrel.log
** [out :: xx.xx.xx.xx] cluster::configure reported an error. Use -h to
get
help.

So what is wrong with the way I approached capistrano mongrel_cluster
?

regards
Roberto

bradley taylor wrote:

Hey y’all:
mongrel_cluster provides management tools for running Mongrel behind
a reverse-proxy/load balancer. It is an extraction from Rails
Machine, a deployment service and Ruby library that simplifies Rails
application deployment. This release fixes bugs and adds a Capistrano
task library.

Good luck and let me know how it works for ya!

This has been VERY helpful, thanks! Two things have come to mind that
might be helpful to include in a future release:

  1. Parse the mongrel_cluster.yml file through ERB, like Rails does for
    the fixtures and database.yml file. Would allow for things like setting
    the CWD to ENV[‘HOME’], etc. Rails uses:

    YAML::load(ERB.new(IO.read(database_configuration_file)).result)

  2. Provide a cluster command for starting up “missing” Mongrel servers.
    The issue is that “restart” only restarts processes that are actually
    running. And just running “start” will do bad things if you just run
    it; it appears to put a new pid into the .pid file, but then fail to
    start up (since a process is running already on that port) – the net
    effect is that the process is now orphaned, since you don’t know the pid
    anymore.

I guess I’m looking for something like the fcgi spinner, that can start
up Mongrel processes if they die. And allow restarts to turn into a
plain old start, if the target process isn’t found.