Platinum Partner

Mongrel Startup Script

I couldn't find one that did exactly what I wanted, so I cooked up this ruby script. Be sure to change app_dir and apps near the top to match your environment. On my ubuntu/debian server, this script resides in /etc/init.d. I ran "sudo update-rc.d -f mongrel defaults" to make it run on startup.


#!/usr/bin/env ruby
#
# mongrel       Startup script for Mongrel by Tim Morgan
#
# chkconfig: - 85 15
# description: mongrel manages Mongrel
#

app_dir = '/var/rails'

apps = {
  'hpy' => 8001,
  '43verses' => 8002
}

if ['stop', 'restart'].include? ARGV.first
  apps.each do |path, port|
    path = File.join app_dir, path
    puts "Stopping #{path}..."
    `mongrel_rails stop -c #{path} -P log/mongrel.pid`
  end
end

if ['start', 'restart'].include? ARGV.first
  apps.each do |path, port|
    path = File.join app_dir, path
    puts "Starting #{path} on #{port}..."
    `mongrel_rails start -d -p #{port} -e production -c #{path} -P log/mongrel.pid`
  end
end

unless ['start', 'stop', 'restart'].include? ARGV.first
    puts "Usage: mongrel {start|stop|restart}"
    exit
end
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}