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
27 Feb 2009

Disagree? Found a typo? Fork the repo and show me how wrong I am.
Got a question? If you'd like to have a conversation about this post, email [email protected]. I don't bite.

You can verify that I've written this post by following the verification instructions:

curl -O https://raw.githubusercontent.com/craigw/craigw.github.com/master/_posts/2009-02-27-running-mongrel-under-daemontools.html \
curl -O https://raw.githubusercontent.com/craigw/craigw.github.com/master/_posts/2009-02-27-running-mongrel-under-daemontools.html.asc
gpg --verify _posts/2009-02-27-running-mongrel-under-daemontools.html{.asc,}