views:

932

answers:

1

I have an interesting request from my client and am trying to figure out the best way to handle it - with a script preferably.

They want me to have 2 sites on production. The first is the actual live website, the second is the last version (in case we need to roll back) and will be the target of the next upgrade. Once the upgrade is done they would like to "swap" all header info (host header, IP, SSL, etc) so we have a minimum of downtime.

I've used the following to allow multiple sites to use 443 with SSL and it works fine:

C:\Inetpub\AdminScripts>cscript.exe adsutil.vbs set /w3svc/1/SecureBindings ":443:www.test.com"

Now, I'd like to figure out how to script a swap of sites which would include dropping then re-adding the SSL mapping.

Any and ALL ideas are welcome as I don't personally think this is the best solution. :)

----- NEW --------------------------------------------------
I think I found the better way to do this.

set PROD1=502916593
set PROD2=1319193536

c:
cd C:\Inetpub\AdminScripts\

cscript.exe adsutil.vbs get W3SVC/%PROD1%/root/path
cscript.exe adsutil.vbs get W3SVC/%PROD2%/root/path

SET CONFIRM=
SET /P CONFIRM=Hit ENTER to make Prod1 active, 2 to make Prod2 active:
IF ?%CONFIRM%? EQU ?? GOTO :P1

:P2
cscript.exe adsutil.vbs set W3SVC/%PROD1%/root/path c:\mywebs\prod2
cscript.exe adsutil.vbs set W3SVC/%PROD2%/root/path c:\mywebs\prod1
GOTO :EOF

:P1
cscript.exe adsutil.vbs set W3SVC/%PROD1%/root/path c:\mywebs\prod1
cscript.exe adsutil.vbs set W3SVC/%PROD2%/root/path c:\mywebs\prod2

:EOF
cscript.exe adsutil.vbs get W3SVC/%PROD1%/root/path
cscript.exe adsutil.vbs get W3SVC/%PROD2%/root/path

Does anyone see any drawbacks to this approach?

+2  A: 

Wouldn't it be better to put something like a load balancer in front of the two servers? The right software would have the intelligence to keep users on the old version for the duration of their session (assuming you're using sessions). Otherwise users will have to log in again when you make the cut-over.

Jeremy Stein
We are on a single PROD server at the moment. When business expands we plan to put a load balancer and multiple web servers behind it. Then we can do rolling promotions of code like you suggest. Until then, on a single sever, I believe this is our solution (though we will still have that momentary hiccup during a push when any attached users lose their session)
Keith Barrows