简体   繁体   English

SVN 用于开发 web 服务器

[英]SVN for development web server

I've checked other threads about this subject, but nothing really answers my exact question.我已经检查了有关此主题的其他线程,但没有真正回答我的确切问题。 I'm currently developing a site that updates data on a live web server (usually photos) multiple times daily using a cron and some external data feeds.我目前正在开发一个站点,该站点每天使用 cron 和一些外部数据馈送多次更新实时 web 服务器(通常是照片)上的数据。 Additionally, we're about to allow user-submitted data.此外,我们即将允许用户提交数据。 Now, I want to start using svn because the project is getting big enough where it's starting to get relatively complicated and people are making edits to our code on the live server.现在,我想开始使用 svn,因为项目变得足够大,开始变得相对复杂,人们正在实时服务器上编辑我们的代码。 I've installed svn for apache and all of the subdomains mentioned below are set up on one server using vhosts.我已经为 apache 安装了 svn,下面提到的所有子域都使用虚拟主机在一台服务器上设置。 We haven't started using this workflow yet, so if I could get some advice before we start it would be greatly appreciated.我们还没有开始使用这个工作流程,所以如果我能在开始之前得到一些建议,我们将不胜感激。

Okay, so I've set up a repository under a subdomain (http://svn.website.com), and checked it out to a development subdomain (http://dev.website.com).好的,所以我在子域 (http://svn.website.com) 下建立了一个存储库,并将其签出到开发子域 (http://dev.website.com)。 I also plan to check out a copy to the live environment (http://www.website.com).我还计划将副本签出到实时环境 (http://www.website.com)。 The idea is to first develop on the dev subdomain, commit when it's ready to go live, and then svn up to the live environment.这个想法是首先在 dev 子域上开发,当它准备好时提交到 go live,然后svn up到 live 环境。 I've read the pros and cons between exporting and updating, and updating seems best for this project because we often will commit small tweaks/code changes and exporting seems like overkill.我已经阅读了导出和更新之间的利弊,更新似乎最适合这个项目,因为我们经常会进行小的调整/代码更改,而导出似乎有点过头了。 I have also setup the appropriate directives to avoid.svn directory access.我还设置了适当的指令来避免.svn 目录访问。 Does it sound like I'm on the right track with this?听起来我在正确的轨道上吗? Anything I should be aware of?有什么我应该注意的吗?

If the following is a good way to take care of everything, then we can move onto the second question.如果以下是处理所有事情的好方法,那么我们可以进入第二个问题。 The user-submitted data (mainly photos) are being uploaded to the live environment.用户提交的数据(主要是照片)正在上传到直播环境。 I have to somehow manage this between the live and dev environment so we can develop with up-to-date user-submitted files.我必须以某种方式在实时环境和开发环境之间进行管理,以便我们可以使用最新的用户提交的文件进行开发。 I don't really know the best way to do this...I feel like there's a serious flaw if I were to svn add and svn ci every time a file is submitted.我真的不知道最好的方法......如果我每次提交文件时都要svn addsvn ci ,我觉得有一个严重的缺陷。 What is the best way to accomplish this?实现这一目标的最佳方法是什么?

Sounds like you're growing!听起来你在成长!

First, I'd question as to whether SVN is really the best choice.首先,我想问一下 SVN 是否真的是最好的选择。 My guess is that you know it already, have worked with it, as have others on your team, and you want to stick with it.我的猜测是你已经知道它,已经使用它,就像你团队中的其他人一样,你想坚持下去。 That's fine, but just an FYI I've used SVN and Git and I found Git generally easier to use, and I would argue that it is becoming more and more commonly used by application developers.没关系,但仅供参考,我使用过 SVN 和 Git,我发现 Git 通常更易于使用,我认为它越来越被应用程序开发人员使用。

As for your workflow, I used to go through an almost identical process with a large distributed team and it worked fine.至于您的工作流程,我曾经通过与大型分布式团队几乎相同的流程使用 go,并且效果很好。 Depending on the amount of traffic you get, I might suggest a different production deployment strategy.根据您获得的流量,我可能会建议不同的生产部署策略。 When you're ready for a new production push, clone into a new directory, labeled perhaps by date or milestone names, and create a new virtual host for that directory.当您准备好进行新的生产推送时,克隆到一个新目录,可能标有日期或里程碑名称,并为该目录创建一个新的虚拟主机。 That way, you get a couple benefits:这样,您将获得几个好处:

  1. You don't run the risk of having someone access your application and requesting a certain file which is in the process of being updated您不会冒让某人访问您的应用程序并请求某个正在更新的文件的风险
  2. You can easily revert back to an earlier milestone by simply changing the active production virtual host.您只需更改活动的生产虚拟主机,即可轻松恢复到较早的里程碑。 Bugs and problems make it out of development regardless of how thoroughly you test, and sometimes they're serious enough to warrant just reverting back to a previous codebase.无论您测试得多么彻底,错误和问题都会导致开发失败,有时它们严重到足以保证恢复到以前的代码库。 Of course, schema changes would add complexity to this, but if we're just talking about code this should avoid frantic commit reverts at 2am.当然,模式更改会增加复杂性,但如果我们只是在谈论代码,这应该避免在凌晨 2 点疯狂的提交恢复。

This was suggested by Rasmus Lerdorf at a conference I attended when he was posed nearly the same question you're asking.这是 Rasmus Lerdorf 在我参加的一次会议上提出的,当时他提出的问题几乎与您提出的相同。

As for ensuring developers are working with the most recent fileset, do you really want to do this?至于确保开发人员使用最新的文件集,您真的要这样做吗? If you're processing a serious quantity of images, that's going to take up a lot of hard disk space.如果您正在处理大量图像,那将占用大量硬盘空间。 Sure with a CDN or other mass storage no big deal, but do you want your developers to have to download 1000 new photos every time they svn up?当然,使用 CDN 或其他大容量存储没什么大不了的,但是您是否希望您的开发人员每次 svn 时都必须下载 1000 张新照片?

If you're dead set on doing this, I'd suggest adding some code within your app for automatically doing an svn add, svn ci when svn status has a certain result (ie, this is a script you could call with cron, or every time new media gets added).如果你死心塌地做这件事,我建议在你的应用程序中添加一些代码来自动执行 svn add, svn ci 当 svn 状态有特定结果时(即,你可以用脚本调用每次添加新媒体时)。 You could also check into using svn hooks (git has these as well) to do things like notify you that the repo has been updated.您还可以检查使用 svn 钩子(git 也有这些)来执行诸如通知您回购已更新之类的事情。

Hope this helps.希望这可以帮助。 I'd strongly discourage including all of the files users upload unless you have a really, really strong reason for doing so.我强烈建议不要包含用户上传的所有文件,除非您有非常非常充分的理由这样做。 The complexity that's gonna add is gonna be a pain = )会增加的复杂性会很痛苦=)

Good luck and welcome to StackOverflow!祝你好运,欢迎来到 StackOverflow!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM