views:

136

answers:

3

Here's my situation:

  • Windows Server
  • Apache
  • CruiseControl

The last step of my CruiseControl deploy scripts copies the build to Apache's htdocs folder, in a "demos" folder (I believe this is referred to as a "hot deploy"?)

All is good and dandy, except that SOMETIMES (not common, but it happens enough that it bugs me), the demos folder doesn't contain the files I built! The old one is gone and the new one isn't there, just vanished.

My gut feeling is that if I try to overwrite a file while someone on the web is downloading it, Apache just deletes it after the download is done? I don't know, it doesn't make any sense.

I looked everywhere and couldn't find even a hint...let's see how good this StackOverflow community really is! :)

Here's the "deploy" target in my ANT script:

<target name="deploy" depends="revertVersionFile">
 <copy todir="${deploy.dir}">
  <fileset dir="${bin.dir}"/>
 </copy>
 <copy todir="${deploy.dir}">
  <fileset dir="${bin.dir}"/>
 </copy>
 <available file="${deploy.dir}/MockupsLive.swf" property="mockupsFile"/>
 <fail unless="mockupsFile" message="MockupsLive doesn't exist!"/>  
 <available file="${deploy.dir}/skins/sketch/sketch.swf" property="skinFile"/>
 <fail unless="skinFile" message="sketch.swf doesn't exist!"/>  
</target>
A: 

Apache won't delete the contents of the directory. Something in the script is removing the contents would be my guess. Does the script create a backup of any kind? Maybe it moves the contents to a backup folder and then copies the build.

You could add a bit of security to that folder to prevent its deletion. Maybe then an error would pop up somewhere and give you an idea as to what is conveniently deleting the directory. :) My guess is its in the script.

hubbardr
Hey hubbardr, I edited the question with my "deploy" target. I don't delte the files, I just copy over them. Twice, in fact (it makes the problem happen less frequently). It's interesting that the available targets never fail...I don't understand.
Peldi
+1  A: 

I would suggest creating a backup of the old files prior to copying the new files out. Name the old files with the timestamp for when they were replaced. Doing this and then seeing what is in the directory the next time it fails will most likely give you a clue as to where to look next.

Alex B
good idea Alex, I'll give it a try.
Peldi
A: 

I think the problem might be somewhere in the CruiseControl file. Most likely what is happening is that the CruiseControl process is tidying up the files somewhere, but maybe due to a lock on the files (potentially by Apache) it cannot write the files back into that folder.

Either way, since "deploy" seems to be the last step, previous steps probably clear the directory and deploy is failing to run, leaving your folder empty at the end of the steps.

Sarat