Ruby Forum JRuby > Redeploying WAR when user-generated files are present

Posted by Myron Marston (Guest)
on 09.08.2008 07:23
(Received via mailing list)
Hello,

My JRuby on Rails application generates lots of files based on user 
input.
These go in a subdirectory under my public directory during development, 
and
under the same subdirectory at the root level of the WAR when packaged 
for
deployment with warbler.  These user-generated files can be regenerated 
from
the user input that is saved in the database, but I'd really rather not
regenerate the files each time I re-deploy because it takes about 2-3
minutes per user submission--which can quickly add up to hours.

How do set things up so that I don't stomp the user-generated files
everytime I deploy my application as a WAR?  I imagine others have dealt
with this problem before...

Thanks,
Myron
Posted by Albert Ramstedt (Guest)
on 09.08.2008 10:43
(Received via mailing list)
I had this same problem. The way I solved it with mri-rails and
capistrano was to setup symlinks after each release was deployed. This
wasnt quite so simple when I deployed WARs since I didn't have a
callback for when the dir was created to hook the symlinks using
capistrano. The way I solved was to just have some code in my
environment.rb to check and setup the symlinks (if they do not already
exist) when the app fired upp. This is ofc rails-specific, but I
imagine that there are other similar places to hook in such code in
other situations.

Albert

On Sat, Aug 9, 2008 at 7:23 AM, Myron Marston <myron.marston@gmail.com> 
wrote:
> How do set things up so that I don't stomp the user-generated files
> everytime I deploy my application as a WAR?  I imagine others have dealt
> with this problem before...
>
> Thanks,
> Myron
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Joel E. Wilson (Guest)
on 10.08.2008 22:54
(Received via mailing list)
I needed to do something similar to set rails.env.  I didn't like the 
Warbler solution of setting it in the web.xml because it meant I'd have 
to edit and redeploy for each environment (dev, staging, production, 
etc.)  So I set a system property in the container (Glassfish, in my 
case) and then have a check for it in environment.rb:

if RUBY_PLATFORM =~ /java/
  the_env = java.lang.System.getProperty("rails.env")
  if the_env
    ENV['RAILS_ENV'] = the_env
  end
end

You could set a property giving the path to this file store and use a 
subdirectory under the Capistrano-created 'shared' directory.  Then 
you'd just need a symlink from public to that location.  I found that 
Glassfish didn't follow these symlinks when serving content, though.  I 
ended up having Apache serve off the public from Capistrano's usual 
location and re-deploying current/tmp/war after each Capistrano 
deployment.

-Joel

----- Original Message -----
From: "Myron Marston" <myron.marston@gmail.com>
To: user@jruby.codehaus.org
Sent: Saturday, August 9, 2008 12:23:33 AM GMT -06:00 US/Canada Central
Subject: [jruby-user] Redeploying WAR when user-generated files are 
present

Hello,

My JRuby on Rails application generates lots of files based on user 
input.
These go in a subdirectory under my public directory during development, 
and
under the same subdirectory at the root level of the WAR when packaged 
for
deployment with warbler.  These user-generated files can be regenerated 
from
the user input that is saved in the database, but I'd really rather not
regenerate the files each time I re-deploy because it takes about 2-3
minutes per user submission--which can quickly add up to hours.

How do set things up so that I don't stomp the user-generated files
everytime I deploy my application as a WAR?  I imagine others have dealt
with this problem before...

Thanks,
Myron

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Myron Marston (Guest)
on 14.08.2008 18:03
(Received via mailing list)
Thanks for the suggestions, guys.

Albert--could you share the code in your environment.rb file that 
creates
the symlinks?  I'm on windows so I really don't have a way to figure 
this
out on my dev machine as windows doesn't support symlinks.

Joel--you mentioned that glassfish doesn't follow the symlinks.  Do you 
(or
anyone else, for that matter) know if Tomcat does?

Thanks,
Myron