List Info

Thread: Multiple rails apps on 1 host




Multiple rails apps on 1 host
user name
2006-08-23 16:05:26
Here is info about my Rails version:


bash mac maco /tmp/app1 114 $
bash mac maco /tmp/app1 114 $
bash mac maco /tmp/app1 114 $ script/about
About your application's environment
Ruby version        ;         1.8.4 (powerpc-darwin8.7.0)
RubyGems version        ;     0.8.11
Rails version        ;        1.1.6
Active Record version        1.14.4
Action Pack version        ;  1.12.5
Action Web Service version   1.1.6
Action Mailer version        1.2.5
Active Support version       1.3.1
Application root   ;          /private/tmp/app1
Environment        ;          development
Database adapter        ;     mysql
bash mac maco /tmp/app1 115 $
bash mac maco /tmp/app1 115 $
bash mac maco /tmp/app1 115 $
bash mac maco /tmp/app1 115 $

-Dan


On 8/23/06, Dan Bikle < dan.biklegmail.com"> dan.biklegmail.com> wrote:
Well,

one strange work-around I found was to make use of this mechanism:

$HTTP[&quot;host&quot;] == "mac2" { ... }

Usually we tie 1 hostname to the ethernet card on a host.

But...
If I tie 2 hostnames to my ethernet card,
I can 'connect' the 2nd hostname to the second rails app.

On my Mac I tied "mac2" to 127.0.0.1 by editing /etc/hosts

Then, I added this syntax to the lighttpd.conf which ties
the 2nd hostname to the rails app.


$HTTP["host"] == "mac2" {
 &nbsp; server.document-root = "/tmp/app2/public"
&nbsp;  server.errorlog   ; &nbsp; = "/tmp/app2" + "/log/lighttpd.error.log&quot;
   accesslog.filename&nbsp;  = "/tmp/app2" + "/log/lighttpd.access.log&quot;



fastcgi.server&nbsp; &nbsp; &nbsp; = ( ".fcgi" => ( "localhost" => (
  "min-procs"  ; &nbsp; &nbsp; => 1,
  "max-procs"  ; &nbsp; &nbsp; => 1,
&nbsp; "socket"&nbsp; &nbsp; &nbsp;   ;  => "/tmp/app2" + "/tmp/sockets/fcgi.socket&quot;,
 ; "bin-path"&nbsp;   ; &nbsp;  => "/tmp/app2" + "/public/dispatch.fcgi";,
  "bin-environment" => ( "RAILS_ENV" => "development&quot; )
) ) )

}


And...
the rails app at /tmp/app2
behaves the way I want.

-Dan


On 8/22/06, Dan Bikle < dan.biklegmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">dan.biklegmail.com> wrote:
Team,

I'm trying to figure out how to run 2 rails apps on one host.

I ran an experiment:

cd /tmp/
rails app1
rails app2
cd app1
script/server

rails put a copy of lighttpd.conf in
/tmp/app1/config/
and then started lighttpd

http://localhost:3000
gave me the splash page.

I shutdown the server

I added something to
/tmp/app1/config/lighttpd.conf

server.modules   ; &nbsp; &nbsp; &nbsp;  = ( "mod_rewrite&quot;, "mod_accesslog&quot;, "mod_fastcgi&quot;, "mod_compress&quot;, "mod_expire";, "mod_alias" )

Then I added 1 other thing:


$HTTP[";url"] =~ "^/app2" {
 alias.url = ( "/app2" => CWD + "/../app2/public" )
 server.error-handler-404 = "/dispatch.fcgi&quot;
 ;server.document-root&nbsp;   ; = CWD + "/../app2/public/"
&nbsp;server.errorlog&nbsp; &nbsp; &nbsp;   ;  = CWD + "/../app2/log/lighttpd.error.log"
 accesslog.filename &nbsp; &nbsp;   = CWD + "/../app2/log/lighttpd.access.log";

fastcgi.server ; &nbsp; &nbsp; = ( ".fcgi" => ( "localhost" => (
  "min-procs"  ; &nbsp; &nbsp; => 1,
  "max-procs"  ; &nbsp; &nbsp; => 1,
  "socket"&nbsp; &nbsp; &nbsp;   ;  => CWD + "/../app2/tmp/sockets/fcgi.socket";,
  "bin-path"&nbsp;   ; &nbsp;  => CWD + "/../app2/public/dispatch.fcgi",
  "bin-environment" => ( "RAILS_ENV" => "development&quot;, "RAILS_RELATIVE_URL_ROOT&quot; => "/app2" )
) ) )

}

I ran script/server from /tmp/app1 to start lighttpd.

It came up fine.

I tried
http://localhost:3000/

I got the rails splash page as before.

I tried
http://localhost:3000/app2/index.html

I got the rails splash page

I tried
http://localhost:3000/app2/

I got a 404 error.

Why is it ignoring the index.html in
/tmp/app2/public/
???


I looked in the error log for app2.

I saw:

2006-08-22 21:39:12: (log.c.75) server started
2006-08-22 21:39:58: (connections.c.1394) Warning: Either the error-handler returned status 404 or the error-handler itself was not found: /dispatch.fcgi
2006-08-22 21:39:58: (connections.c.1396) returning the original status 404
2006-08-22 21:39:58: (connections.c.1398) If this is a rails app: check your production.log

I shutdown lighttpd.

I tinkered with a variety of settings in
/tmp/app1/config/lighttpd.conf

I couldn't get app2 to "see&quot; index.html unless I typed it into the URL.

Can any of you give me some tips on how I might force lighttpd to see index.html ?

Related question:

How do I force app1 to ignore /app2/ as a route ?

Thanks,

-Dan



[1]

about | contact  Other archives ( Real Estate discussion Medical topics )