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

Rick Olson http://techno-weenie.net

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

running multiple domains off a single rails app with different page caching directories

Problem: You have multiple instances of a rails app that use page caching, but you'd rather not set up a separate instance for each one.

Lighttpd config:
   1  #... normal lighty conf...
   2  server.document-root = "/home/rails/app/public/"
   3  server.error-handler-404 = "/dispatch.fcgi"
   4  fastcgi.server = (
   5    ".fcgi" =>
   6      ("localhost" =>
   7        (
   8         "min-procs" => 1,
   9         "max-procs" => 1,
  10         "socket" => "/tmp/rails-fcgi1.socket",
  11         "bin-path" => "/home/rails/app/public/dispatch.fcgi",
  12         "bin-environment" => (
  13           "RAILS_ENV" => "production",
  14           "TZ"        => "America/Chicago"
  15         )
  16       )
  17      )
  18   )
  19  
  20  $HTTP["host"] =~ "site1.net" {
  21    server.document-root = "/home/rails/app/public/site1.net"
  22  }
  23  $HTTP["host"] =~ "site2.net" {
  24    server.document-root = "/home/rails/app/public/site2.net"
  25  }


Rails code to set the page cache directory:

   1  before_filter { |c| c.class.page_cache_directory = "#{RAILS_ROOT}/public/#{c.request.host}" }


Remember to symlink your necessary files AND your dispatch.fcgi to each page cache directory.

manual reaping of fcgi processes

These are the signals that SwitchTower's reaper uses:

   1  # reload
   2  kill -s HUP @pid
   3  
   4  # graceful
   5  kill -s TERM @pid
   6  
   7  # kill
   8  kill -9 @pid
   9  
  10  # usr1
  11  kill -s USR1 @pid
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS