Is smooth deployment possible with componentized ASP.NET MVC apps?

前端 未结 2 1158
梦谈多话
梦谈多话 2020-12-08 08:31

That\'s probably not MVC specific, it might as well applicable to ASP.NET WebForms, but we\'ve been experiencing it on MVC2 so far.

Whenever we start remote deployme

相关标签:
2条回答
  • 2020-12-08 09:16

    Overlapping rotation only applies to pool recycling and is not intended to facilitate the type of deployment you're describing or require. When overlapping rotation is enabled, existing requests in a pool's "outgoing" worker process will be allowed to complete whilst new requests will be sent to the new worker process created. It's a mechanism to gracefully handover to a new worker process without pulling the rug from underneath existing requests. That's all it does.

    Shadow copy folders are used for this purpose:

    What is the “Temporary ASP.NET Files” folder for? (My Answer)

    Again they are not intended to provide a mechanism to facilitate keeping a whole existing code base running whilst you upload a new site.

    When you deploy an ASP.NET application the site will misbehave. Whilst you are copying your assemblies these files will be locked (probably exclusively) by whatever process is handling the upload (WebDAV or FTP).

    This causes the exceptions you've observed and are most likely because the shadow copy mechanism can't read the new assemblies until they are written (and WebDAV or FTP removes the write locks).

    Additionally, any pages that have dependencies on these assemblies may not (shadow) compile if expected method signatures have changed or been removed until the correct pages have been uploaded. Or if the pages/views upload first that depend on functionality in assemblies that haven't yet been deployed you will also get errors.

    The whole site will be in an inconsistent state until the last file is deployed.

    There is no built-in mechanism in IIS to ensure an "atomic" deployment, i.e. load all your stuff then switch over to running that. IIS will keep serving requests to the site and ASP.NET will still keep detecting file changes as you upload the application.

    The only way to deploy an application without generating these errors this is to enable a special page called App_Offline.htm before deployment and then rename or remove after deployment:

    App_Offline.htm - Scott Guthrie
    App_Offline.htm and working around the "IE Friendly Errors" feature

    You may also find this article useful:

    How to: Prepare to Deploy a Web Project

    There is a slightly more convoluted alternative which involves having two folders, for example:

    d:\websites\site\www-A d:\websites\site\www-B

    The running site is pointing at d:\websites\site\www-A, meanwhile you deploy into d:\websites\site\www-B. When you're ready you switch the site to the d:\websites\site\www-B folder.

    When you come to deploy the next built you deploy into d:\websites\site\www-A and switch to that when you're happy.

    The drawback is that you need to be on your toes and remember which folder is which.

    Also any user uploaded content would need to be synchronised between the two folders (although you could have a third folder mapped into to a virtual directory for stuff like that).

    0 讨论(0)
  • 2020-12-08 09:25

    My deployment script stops the website and displays a "Please wait while the site is being updated..." page, which refreshes every 15 seconds. Since the deployment takes under a minute it seems to fix the problem.

    0 讨论(0)
提交回复
热议问题