I've installed DaemonTools to make sure that the various services I run are up and behaving reasonably nicely. Since I also run plenty of Rails applications I use this DaemonTools script to keep Mongrel running.

#!/bin/sh
exec 2>&1

echo "Starting..."

ENVIRONMENT=production
PORT=8000
IP=0.0.0.0

CHDIR=/var/www/www.application.com
USER=application_user

exec softlimit -m 134217728 \
     setuidgid $USER \
     env HOME=$CHDIR \
     mongrel_rails start -e $ENVIRONMENT -p $PORT -a $IP -c $CHDIR 2>&1

Create a separate service for each Mongrel you'd like to run and change the PORT variable in the script.

written by
Craig
published
2009-02-27
Disagree? Found a typo? Got a question?
If you'd like to have a conversation about this post, email craig@barkingiguana.com. I don't bite.
You can verify that I've written this post by following the verification instructions:
curl -LO http://barkingiguana.com/2009/02/27/running-mongrel-under-daemontools.html.orig
curl -LO http://barkingiguana.com/2009/02/27/running-mongrel-under-daemontools.html.orig.asc
gpg --verify running-mongrel-under-daemontools.html.orig{.asc,}