为什么我的热部署文件有时会消失? (我认为阿帕奇吃掉了它们)
这是我的情况:
- Windows Server
- Apache
- CruiseControl
我的 CruiseControl 部署脚本的最后一步将构建复制到 Apache 的 htdocs 文件夹中的“demos”文件夹中(我相信这被称为“热部署”?)
一切都很好。 ,除了有时(不常见,但它发生的次数足以让我烦恼),演示文件夹不包含我构建的文件! 旧的已经消失,新的也不存在,只是消失了。
我的直觉是,如果我尝试在网上有人下载文件时覆盖该文件,Apache 会在下载完成后删除它? 我不知道,这没有任何意义。
我到处找遍了,连一点提示都没有找到……让我们看看这个 StackOverflow 社区到底有多好! :)
这是我的 ANT 脚本中的“部署”目标:
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Apache 不会删除该目录的内容。 我猜测脚本中的某些内容正在删除内容。 该脚本是否创建任何类型的备份? 也许它将内容移动到备份文件夹,然后复制构建。
您可以向该文件夹添加一些安全措施以防止其被删除。 也许某个地方会弹出一个错误,让您知道什么可以方便地删除该目录。 :) 我的猜测是在脚本中。
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.
我认为问题可能出在 CruiseControl 文件中的某个地方。 最有可能发生的情况是 CruiseControl 进程正在某处整理文件,但可能由于文件锁定(可能由 Apache),它无法将文件写回该文件夹。
无论哪种方式,由于“部署”似乎是最后一步,前面的步骤可能会清除目录并且部署无法运行,从而在步骤结束时使文件夹为空。
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.
我建议在复制新文件之前创建旧文件的备份。 使用替换时的时间戳来命名旧文件。 执行此操作,然后在下次失败时查看目录中的内容,很可能会为您提供下一步查找位置的线索。
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.