# Redeploying WAR when user-generated files are present

**URL:** <https://www.ruby-forum.com/t/redeploying-war-when-user-generated-files-are-present/145431>\
**Category:** JRuby\
**Created:** [August 9, 2008, 7:23am UTC](https://www.ruby-forum.com/t/redeploying-war-when-user-generated-files-are-present/145431 "2008-08-09T07:23:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Myron\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Myron\_M](https://www.ruby-forum.com/u/Myron_M)\
**Post date:** [August 9, 2008, 7:23am UTC](https://www.ruby-forum.com/t/redeploying-war-when-user-generated-files-are-present/145431/1 "2008-08-09T07:23:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Myron\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Myron\_M](https://www.ruby-forum.com/u/Myron_M)\
**Post date:** [August 9, 2008, 10:43am UTC](https://www.ruby-forum.com/t/redeploying-war-when-user-generated-files-are-present/145431/2 "2008-08-09T10:43:52Z")

</div>

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 M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

```

---

<div class="post-metadata">

**Author:** ![Myron\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Myron\_M](https://www.ruby-forum.com/u/Myron_M)\
**Post date:** [August 10, 2008, 10:54pm UTC](https://www.ruby-forum.com/t/redeploying-war-when-user-generated-files-are-present/145431/3 "2008-08-10T22:54:57Z")

</div>

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 M.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: removed\_email\_address@domain.invalid  
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

```

---

<div class="post-metadata">

**Author:** ![Myron\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Myron\_M](https://www.ruby-forum.com/u/Myron_M)\
**Post date:** [August 14, 2008, 6:03pm UTC](https://www.ruby-forum.com/t/redeploying-war-when-user-generated-files-are-present/145431/4 "2008-08-14T18:03:19Z")

</div>

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
