Skip to content

Instantly share code, notes, and snippets.

@rahul100885
rahul100885 / sphinx
Created May 19, 2011 15:31
Simple starup service using ruby
#!/usr/bin/env ruby
RAILS_CODE_PATH='/home/rahul/workspace/livia_portal_3/livia_portal/'
RAKE_PATH='/usr/local/rvm/gems/ree-1.8.7-2010.02@global/bin/rake'
USER="rahul"
case ARGV[0]
when "start"
STDOUT.puts "called start"
system "su - #{USER} -c \"cd #{RAILS_CODE_PATH} && #{RAKE_PATH} ts:rebuild\""
@rahul100885
rahul100885 / monitor_passenger_rails_instances
Created February 11, 2011 05:08
This script will kill a rails instance which is taking more than 500 MB and retsrat a request if it has served 100 requests
#!/bin/sh
while true; do
passenger-memory-stats | grep Rails:\ /home | awk ' { if($2 > 500) print "kill -9 " $1}' | bash
# above line will kill all the rails instances which are using memory more than 500MB
passenger-status | grep Processed: | awk ' { if($7 > 100) print "kill -6 " $3}' | bash
# above line will abort all rails instance who have processed 100 request.