Mongrel: auto-reload plugins?

When developing applications, Webrick will automatically reload
controllers, models, etc. if the source changes. For obvious reasons,
it
doesn’t do this for plugins, which makes it a pain to develop said
plugins.

I was hoping Mongrel might have some facility to say “watch this
directory
too and reload any changes”. Obviously, re-init’ing all plugins would
be
performance-killing, but simply reloading the lib dir of a given plugin
should be no worse than reloading models and controllers - and, let’s
face
it, how often does init.rb change when you’re developing a plugin?

So… is there some way to get Mongrel to automatically reload my plugin
when it changes?

Jay L.

On Mon, 2006-07-24 at 19:09 -0400, Jay L. wrote:

So… is there some way to get Mongrel to automatically reload my plugin
when it changes?

Nope, not unless you write something to do it. I think best you could
do would be to have something else watch your plugins and kick mongrel a
restart signal.


Zed A. Shaw


http://mongrel.rubyforge.org/
http://www.railsmachine.com/ – Need Mongrel support?

On Mon, 24 Jul 2006 19:29:53 -0400, Zed S. wrote:

So… is there some way to get Mongrel to automatically reload my plugin
when it changes?

Nope, not unless you write something to do it. I think best you could
do would be to have something else watch your plugins and kick mongrel a
restart signal.

Fair enough. What makes Mongrel reload other files - is the “app” dir
magic? I’m wondering if there’s a way to genericize that magic and make
it
configurable.

Also, I’m not clear how to do restarting on Windows, since there are no
signals. mongrel_rails restart complains about a missing pid file. Is
this currently supported only via the Windows Services interface?

Jay

AWDWR v2beta5 talks on page 106 about adding “include Reloadable” at
the top of models that are not ActiveRecord sublasses.

Also, try “putting a require_dependency ‘my_module’ just before the
include MyModule call.”
http://www.ruby-forum.com/topic/68613
http://weblog.techno-weenie.net/2006/2/21/unitialized-constant-
technoweenie

        - dan


Dan K. mailto:[email protected]
http://www.dankohn.com/ tel:+1-415-233-1000

Dan K. wrote:

AWDWR v2beta5 talks on page 106 about adding “include Reloadable” at
the top of models that are not ActiveRecord sublasses.

Is Reloadable only triggered in Development, and ignored in Production?

Production never reloads any code; to do so would slow down the
server.

  • james

On Tue, 2006-07-25 at 03:20 -0400, Jay L. wrote:

magic? I’m wondering if there’s a way to genericize that magic and make it
configurable.

Mongrel doesn’t do this, Rails does. Sorry.

Also, I’m not clear how to do restarting on Windows, since there are no
signals. mongrel_rails restart complains about a missing pid file. Is
this currently supported only via the Windows Services interface?

Oh, yeah you’re double screwed there. Ruby on windows is just seriously
lacking in a lot of things. You can get it running under cygwin, maybe
you can send it signals that way. Give that a try if you really need
it.

The only other thing I can say is maybe it’s time to change your tactic.
Instead of relying on refresh to test your libraries and plugins, rely
more on heftier unit tests. That’s typically what I do.


Zed A. Shaw


http://mongrel.rubyforge.org/
http://www.railsmachine.com/ – Need Mongrel support?

On Tue, 25 Jul 2006 00:54:59 -0700, Dan K. wrote:

AWDWR v2beta5 talks on page 106 about adding “include Reloadable” at
the top of models that are not ActiveRecord sublasses.

Also, try “putting a require_dependency ‘my_module’ just before the
include MyModule call.”

Hmm… Reloadable doesn’t seem to help for a plugin class - and I’m
developing a behavior for Radiant, not a module, so I can’t control how
it’s loaded.

Ah well. Restarting it is, I guess.

Jay

But I believe you can force a reset with Dispatcher.reset_application!

        - dan


Dan K. mailto:[email protected]
http://www.dankohn.com/ tel:+1-415-233-1000

On Tue, 25 Jul 2006 12:22:55 -0400, Zed S. wrote:

On Tue, 2006-07-25 at 03:20 -0400, Jay L. wrote:

Fair enough. What makes Mongrel reload other files - is the “app” dir
magic? I’m wondering if there’s a way to genericize that magic and make it
configurable.

Mongrel doesn’t do this, Rails does. Sorry.

Ah! That’ll give me some ideas where to poke.

Oh, yeah you’re double screwed there. Ruby on windows is just seriously
lacking in a lot of things. You can get it running under cygwin, maybe
you can send it signals that way. Give that a try if you really need
it.

Triple screwed - I’m using Eclipse to debug, and running cygwin ruby
from
Eclipse (which is the same as running it from CMD.EXE) gives weird
results
with some native libs such as ImageMagick, for reasons I haven’t been
able
to figure out yet. So I have to use the mswin32 version for now.

The only other thing I can say is maybe it’s time to change your tactic.
Instead of relying on refresh to test your libraries and plugins, rely
more on heftier unit tests. That’s typically what I do.

Usually I do, but I’m writing a graphical library, and some things you
can
check only by eye… actually, I’m sure someone could develop some nice
recognition algorithms, but I think that’s beyond the scope of unit
tests!

Jay

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs