Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Tim Morgan http://timmorgan.org

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

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.

   1  
   2  #!/usr/bin/env ruby
   3  #
   4  # mongrel       Startup script for Mongrel by Tim Morgan
   5  #
   6  # chkconfig: - 85 15
   7  # description: mongrel manages Mongrel
   8  #
   9  
  10  app_dir = '/var/rails'
  11  
  12  apps = {
  13    'hpy' => 8001,
  14    '43verses' => 8002
  15  }
  16  
  17  if ['stop', 'restart'].include? ARGV.first
  18    apps.each do |path, port|
  19      path = File.join app_dir, path
  20      puts "Stopping #{path}..."
  21      `mongrel_rails stop -c #{path} -P log/mongrel.pid`
  22    end
  23  end
  24  
  25  if ['start', 'restart'].include? ARGV.first
  26    apps.each do |path, port|
  27      path = File.join app_dir, path
  28      puts "Starting #{path} on #{port}..."
  29      `mongrel_rails start -d -p #{port} -e production -c #{path} -P log/mongrel.pid`
  30    end
  31  end
  32  
  33  unless ['start', 'stop', 'restart'].include? ARGV.first
  34      puts "Usage: mongrel {start|stop|restart}"
  35      exit
  36  end

Add a FAT32 partition to your fstab

I always forget how to do this because I don't do it very often.

   1  
   2  /dev/hda6 /media/stuff vfat rw,uid=1000,gid=1000 0 0


1000=first user created (at least in Ubuntu)
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS