简体   繁体   English

版本控制的生产环境

[英]Version controlled production environment

My question is, how do I version control the production environment in a good way? 我的问题是,如何以良好的方式对生产环境进行版本控制?

This is our current environment: 这是我们当前的环境:

  • (Internal server) Development - Version controlled source code (内部服务器)开发-版本控制的源代码
  • (Customer server) Acceptance test environment (客户服务器)验收测试环境
  • (Customer server) Staging environment (客户服务器)暂存环境
  • (Customer server) Production environment (客户服务器)生产环境

When we release new functionality for acceptance testing, we make a publish in Visual Studio, zip up the changes and apply them on the Test Server. 当我们发布用于验收测试的新功能时,我们将在Visual Studio中进行发布,压缩更改并将其应用到测试服务器上。 There we make a backup folder (so that we can revert the changes) and we make a release folder so that we can move these changes to Staging when they're approved. 在那里,我们创建了一个备份文件夹(以便我们可以还原更改),并创建了一个发布文件夹,以便我们可以在批准这些更改后将其移至暂存。

This is a lot of manual labour creating backup folders, release folders, recreating the directory structure and try to track what functionality that goes into what release. 这需要大量的人工来创建备份文件夹,发布文件夹,重新创建目录结构并尝试跟踪发布到哪个版本中的功能。 It is teadious and there is always problem with some developer not following the release procedure. 这很挑剔,某些开发人员总是不遵循发行程序就存在问题。


In theory I could make a repository for the test environment. 从理论上讲,我可以为测试环境建立一个存储库。 (forget source code, this is about the published application) On every release the developer do a commit and supply a comment about the functionality he's releasing. (忘记源代码,这是关于已发布的应用程序的。)在每个发行版上,开发人员都要进行提交并提供有关其发行功能的注释。

When functionality should be moved from Test to Staging we export changes made from the last date Staging environment was updated and copy them into the Staging application. 当功能应从“测试”转移到“登台”时,我们将导出自上次登台环境更新日期以来所做的更改,并将其复制到“登台”应用程序中。 There we do a commit that later can be extracted for release to Production environment. 在那里,我们做了一个提交,以后可以将其提取以发布到生产环境。

The drawbacks of this is that using subversion will clutter the application with those .svn directories. 这样做的缺点是使用Subversion将使那些.svn目录的应用程序混乱。 This may be mended by disallowing access to those directories in the IIS or web.config. 可以通过禁止访问IIS或web.config中的那些目录来解决此问题。 Another solution would be using Git on the directory above the root directory of the application. 另一种解决方案是在应用程序根目录上方的目录上使用Git。 But Git is harder to work with for an unexperienced developer in a windows environment. 但是对于在Windows环境中没有经验的开发人员来说,与Git的合作更加困难。

Does anyone have experience of this problem? 有人有这个问题的经验吗? How do you version control your production environment? 您如何版本控制生产环境? What if you need to revert a release, do you have a backup folder that you created before the release? 如果需要还原发行版,该发行版之前是否创建了一个备份文件夹,该怎么办?

I've discussed this with our developers, and they can't see any problem with using subversion for versioning and backup of the test/staging/production environment. 我已经与我们的开发人员讨论了这一点,他们看不到将Subversion用于测试/过渡/生产环境的版本控制和备份的任何问题。 Quite the opposite would they be happy not to create release/backup folders every time they need to release new functionality. 相反,他们很乐意在每次需要发布新功能时不创建发布/备份文件夹。

At the same time there is some insecurity about this. 同时,对此存在一些不安全感。 None have heard of this before, having the application in a version control system and we are unsure what the drawbacks would be. 以前没有人听说过,将应用程序放在版本控制系统中,我们不确定会有什么弊端。

If you have experience of a scenario like this, I would be happy to hear about it. 如果您有这种情况的经验,我很乐意听到。

Mikael Lundin 米凯尔·伦丁(Mikael Lundin)

Another way to do things would be to use a build server. 另一种处理方法是使用构建服务器。 Every time you check in code the build server builds and packages up the new build inside the development environment. 每次您签入代码时,构建服务器都会在开发环境中构建并打包新的构建。 Then checks in the deployable package with your code. 然后使用您的代码检入可部署的程序包。

You can then deploy the packaged build to the other environments. 然后,您可以将打包的内部版本部署到其他环境。 This way you don't have to back up the versions there because you already have all the built versions in your main repository. 这样,您不必在那里备份版本,因为您已经在主存储库中拥有所有构建的版本。 If you make sure deployment is fully automated and can be done with one command (powershell?) there's no need to keep backups on the servers anymore. 如果您确保部署是完全自动化的,并且可以使用一个命令(powershell?)完成部署,则无需再在服务器上保留备份。

This is actually better and more maintainable than the solution you propose. 实际上,这比您提出的解决方案更好,更可维护。 Because every version of the build is kept alongside the code you can always find a complete development environment for any build package. 因为构建的每个版本都与代码一起保存,所以您始终可以为任何构建包找到完整的开发环境。 If you version-control your servers separately and you find a bug somewhere it can be hard to find the version of the code that causes the bug. 如果单独对服务器进行版本控制,并且在某处发现错误,则可能很难找到导致该错误的代码版本。

I been using mercurial (Hg) as a production version control system. 我一直使用 (Hg)作为生产版本控制系统。 (Not the code, but the actually deployed binaries). (不是代码,而是实际部署的二进制文件)。 That works quite well. 效果很好。 Subversion isn't quite right to use in my scenario because I do want to be able to sync production changes (such as config files) back to testing and maybe even development. 在我的场景中,Subversion不太适合使用,因为我确实希望能够将生产更改(例如配置文件)同步回测试甚至开发。 subversion is harder to sync/merge between different repositories ( a lot of manually coping). Subversion很难在不同的存储库之间同步/合并(很多手动处理)。 And with hg tag and hg update there is a breeze to revert to a stable (or unstable) tag. 使用hg标签和hg更新,可以轻而易举地恢复到稳定(或不稳定)的标签。

Oh, and I totaly agree, you should use a buildserver (cruisecontrol.net) or something and keep all your things there as well. 哦,我完全同意,您应该使用构建服务器(cruisecontrol.net)或其他任何东西,并将所有内容也保存在那里。 I my scenario that isn't enough because the config of a customers production system is, well, custom specific, and even with extensive testing and what not there can be some config that no longer do the same thing between two releases (or the incoming data has significantly changed) 我的情况还不够,因为客户生产系统的配置是特定于自定义的,即使进行了广泛的测试,没有什么配置,在某些两个发行版(或新发行版)之间也可能不再做相同的事情数据已发生重大变化)

We use subversion as a way to deploy things to our different servers(prod, demo, dev, etc.) and have not run into any difficulties. 我们使用Subversion作为将事物部署到我们的不同服务器(产品,演示,开发等)的一种方式,并且没有遇到任何困难。 The only things to watch out for are database differences and config file differences. 唯一需要注意的是数据库差异和配置文件差异。 The config files can be templatized, so as not to overwrite the files in each different deployment, but then you don't get those versioned for the changes to that specific platform. 可以对配置文件进行模板化,以免在每个不同的部署中覆盖这些文件,但是对于特定平台的更改,您不会获得这些版本的版本。

With this sort of a system, you can make use of subversion's tags to update/roll back to specific deployment versions easily. 使用这种系统,您可以利用subversion的标签轻松地将其更新/回滚到特定的部署版本。

Thank you for your answers and suggestions. 感谢您的回答和建议。

I see that I need to rethink the way we handle releases to these environments. 我发现我需要重新考虑我们处理这些环境的发布的方式。 Having a build server with all the releases ever made could solve a part of the problem. 拥有所有发布版本的构建服务器可以解决部分问题。 I will get the commit comments on the source code, and much better control of what feature goes into what build. 我将在源代码上获得提交注释,并更好地控制将什么功能集成到什么版本中。 I still need to keep track on what build is in what environment to be able to revert a release if something went wrong. 我仍然需要跟踪在什么环境中构建什么版本,以便在出现问题时能够还原发行版。

@Jonke I will take a look at Mercurial. @Jonke我将看一下Mercurial。 Maybe a version controlled production environment is overkill if you have a build system where each revision has version controlled source code. 如果您有一个构建系统,其中每个修订版都具有版本控制的源代码,则版本控制的生产环境可能会显得过分。 But I would still like to have a fast way to revert changes to a previous revision if anything goes wrong during deployment of new functionality. 但是,如果在部署新功能期间出现任何问题,我仍然希望有一种快速的方法将更改还原到以前的版本。 I also like the way you get version controlled configuration files on the server, since production environment always have different configuration from the development environment. 我还喜欢在服务器上获取版本控制的配置文件的方式,因为生产环境始终具有与开发环境不同的配置。

Maybe I'm looking for the silver bullet :) 也许我在寻找银弹:)

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

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