I'm trying to get a reasonable understanding of how one can build an app on top of ruby/rack (or even more ideally, an existing framework) that manages something equivalent to WordPress. Specifically, with the ability to serve multiple sites from the same code base, each with its own features and configuration.
Suppose, for instance:
- example.com using auth, pages, blog modules
- forum.example.com -> auth, forum modules
- api.example.com -> auth, api modules
This test case seems to work, including in a production environment:
# test.rb
class Foo
end
# config.ru
require 'rack'
use Rack::ShowExceptions
use Rack::CommonLogger
run lambda { |env|
case env['HTTP_HOST']
when /^test./
require './test'
# answers true, regardless of subdomain loaded first
[200, {'Content-Type'=>'text/plain'}, "#{Kernel.const_defined? :Foo}"]
else
# answers false, regardless of subdomain loaded first
[200, {'Content-Type'=>'text/plain'}, "#{Kernel.const_defined? :Foo}"]
end
}
Having mostly worked in environments with little if any state until now, however, I'm a bit nervous that this might come back and bite me down the road.
At any rate, what did I miss/where should I expect it to come back and bite me? (Performance due to file reloads? DB connection pools that need to be re-initialized if appropriate? Sessions being invalidly shared across different domains? etc. besides the obvious fact that any caching as static files will be inappropriate.)
And, is there any app around that allows to do this out of the box?
(My initial impression with Rails was that it won't fit for such a use-case. Perhaps wrongly. The only multisite plugin I ran into was to allow example.com/site1, example.com/site2, etc.)
These two threads exemplify what I'm worried about:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…