On Tue, Apr 13, 2010 at 8:39 PM, Pete <p...@kapiti.co.nz> wrote:
> Hi Luis,
>
> First up, I'm still using Rails 2.2.2.
>
> I'm sorry, but I don't agree with you that a single code base for multiple
> different rails application is a bad idea, quite the opposite actually. If
> you're really interested in what we're doing, this thread explains it in
> more detail: http://railsforum.com/viewtopic.php?pid=74217.
>

You're preaching to the wrong choir.

I was the one that originated the approach of Radiant to build
applications, and make gems of Rails applications with custom
settings, database and configuration files. It was called fossilize,
but due the constant internal changes of Rails was hard to keep it up.

Since now is based on Rack (Rails 3), it might be easy to resurrect the idea.

> It shouldn't be too hard to see the many advantages of a single code base
> over multiple code bases for serving multiple clients similar applications.
>

Is not that is hard to see, is hard to wrap Rails around that concept

Reading your post what you actually need is more in the lines of
Radiant approach:

* make your application a gem
* use a single directory for each individual application, but still
depend on the same gem
* extend or change the application with extensions from vendor, that
might be different from client A to client B

> As I said, I played with the --script option but couldn't get it to work.
> Here is how I start mongrel from the command line for client FOO:
>
> mongrel_rails start -e production -p 3035 -l "log/FOO/mongrel.log" -S
> "config/FOO/myapp_opts.rb" -c "x:/myapp"
>
> But config/FOO/myapp_opts.rb is never loaded (I've also tried specifying the
> full path "x:/myapp/config/FOO/myapp_opts.rb" to no avail). If this worked,
> it would solve my problem. So what am I doing wrong?

According to this:

http://github.com/fauna/mongrel/blob/master/bin/mongrel_rails#L122-125

And this:

http://github.com/fauna/mongrel/blob/master/lib/mongrel/configurator.rb#L342-348

The purpose of the config script is internal of Mongrel, not to setup
stuff globally for the application like Rails.

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Loading config/init_mongrel.rb external config script

Also, it happens "after" Rails initialization.

I would suggest you try the following:

1) put your init script code inside config/preinitializer.rb

It gets executed by boot before Rails::Initializer.run of environment.rb.

example:

>type config\preinitializer.rb
STDERR.puts ARGV.inspect

2) Use something like MYAPP_TARGET=foo in the command line:

mongrel_rails start MYAPP_TARGET=foo

Will get you something like this:

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
["MYAPP_TARGET =foo"]
["MYAPP_TARGET =foo"]
** Rails loaded.
** Loading any Rails specific GemPlugins

(dunno why appears twice, is like the file gets "loaded" instead of required)

3) Add the additional parameter to created mongrel_service manually
(registry editing)

At this time, there is no way to specify additional parameters. I
would like to move the configuration from command line to the
registry, so is more easy to manipulate.


That helps somehow?

Thank you for explaining in further detail your need, it helped me
provide you a better alternative. Of course, there is still room for
improvement, and patches are always welcomed ;-)

-- 
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
_______________________________________________
Mongrel-users mailing list
Mongrel-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-users

Reply via email to