Plasticx Blog

Capable of being shaped or formed

Gentoo init.d script for a Rails mongrel cluster

Posted by Mike 12/23/2007 at 02:45PM

Here is my Gentoo init.d script for a mongrel cluster running a Rails app.



depend() {
        need net
        use apache2 mysql
        after apache2 mysql

start() {
        ebegin "Starting mongrels"
        start-stop-daemon --start --chuid $USER --exec $MONGREL \
        -- cluster::start -C $MONGREL_CONF
        eend $?

stop() {
        ebegin "Stopping mongrels"
        start-stop-daemon --start --chuid $USER --exec $MONGREL \
        -- cluster::stop -C $MONGREL_CONF
        eend $?

status() {
        ebegin "mongrel status"
        start-stop-daemon --start --chuid $USER --exec $MONGREL \
        -- cluster::status -C $MONGREL_CONF
        eend $?


Gentoo will load script variables for an init.d script from the /etc/conf.d directory where the conf file is the same name is the init.d file. Thus in /etc/conf.d/mongrel


Some things to point out:

  • this integrates perfectly with Gentoo’s rc-status command
  • the mongrel cluster will be running as the user/group defined in USER (i.e. safer non-root)
  • mongrel_cluster.conf is a standard mongrel cluster configuration that you would have generated with Capistrano, Vlad or written by hand
  • start-stop-daemon command is executed in —start mode because all of the commands ‘start’ ‘stop’ ‘restart’ ‘status’ are delegated to the mongrel_rails executable
  • because you are running the commands as a non-root user your Capistrano or Vlad tasks (rake vlad:start_app) will still work from your remote shell (you’re not running as root through ssh right!?)

Posted in , , |

RV2 Camping on Gentoo

Posted by Mike 07/05/2007 at 03:57PM

Evan Weaver wrote a SysV init.d setup for daemonizing Camping apps on a *Nix system and documents it in rv, a tool for luxurious camping

I used that blog entry as a reference to build one called RV2 that is a little bit more Gentoo specific. Here are my scripts and directory layout

Posted in , , , |

Maintaining Your Own Typo 4.0.3

Posted by Mike 04/08/2007 at 05:12PM

This is the combined experience from my previous entry Typo 4.0 + Apache2 + MySQL + Gentoo and Chapter 27 Deployment and Production / Agile Web Development with Rails and Capistrano: Automating Application Deployment

What I am illustrating here is how to maintain a Typo blog. What I mean by maintain is that you are creating your own
source repository for your instance of Typo. This will allow you to patch the application with fixes and your own
modifications. You will also integrate Capistrano into your repository so that you deploy your updates with ease.
Also, I show you my implementation of a Mongrel init.d script on Gentoo that will ensure Mongrel starts back up on
server reboot.

Posted in , , , , |

Web Statistics