From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Multiple rack applications on the same server with unicorn
Date: Fri, 30 Sep 2011 17:16:08 +0000 [thread overview]
Message-ID: <20110930171608.GA10578@dcvr.yhbt.net> (raw)
In-Reply-To: <CAOf2Z5t+artehpTPuror3vSiOBmavAceyYOidgS8qyYVJWNL1g@mail.gmail.com>
John Joseph Bachir <johnjosephbachir@gmail.com> wrote:
> If I'm running two rails apps on the same server using Unicorn, I have
> to run two instances of Unicorn, right?
I'm not sure if Rails (or any other frameworks) has issues, but plain
Rack applications will work. Rack lets you do something like this in
config.ru:
--------------------- config.ru ------------------
map("http://foo.example.com/") do
run FooApp.new
end
map("http://bar.example.com/") do
run BarApp.new
end
----------------------- 8< -----------------------
Both applications need to be able to work from the same working
directory, though.
> If so, then here's a place where passenger might win in terms of
> memory use, as the rails code will be loaded into memory twice, right?
It's all dependent on whether Rails lets you run two apps in the same
process or not (in which case Unicorn can do it).
The following example is pretty ugly, but lets you split your workers
between two applications:
----------------- unicorn.conf.rb -----------------
preload_app false
worker_processes 2 # need more than one
after_fork do |server,worker|
$unicorn_worker_nr = worker.nr
end
---------------------------------------------------
--------------------- config.ru ------------------
if ($unicorn_worker_nr % 2) == 0
run FooApp.new
else
run BarApp.new
end
----------------------- 8< -----------------------
--
Eric Wong
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying
next prev parent reply other threads:[~2011-09-30 17:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-30 17:04 Multiple rack applications on the same server with unicorn John Joseph Bachir
2011-09-30 17:16 ` Eric Wong [this message]
2011-09-30 19:50 ` Hongli Lai
2011-10-01 3:34 ` John Joseph Bachir
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110930171608.GA10578@dcvr.yhbt.net \
--to=normalperson@yhbt.net \
--cc=mongrel-unicorn@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).