quinta-feira, 23 de fevereiro de 2017

Automatic Simple Cluster Process. - IIS + .NET Core + Cluster + HAProxy

@echo off
rem Fabio Leandro Lapuinka
rem 11:30 AM 12/30/2016 Publish Cluster

set arquivoDestino=E:\system\LPK.iso
set applicationPoolName=app_devcluster
set servidorOrigem=ftp://LPK-99/LPK.iso
set DELAY=5
set scripts=e:\scripts\

    echo [ run ] - Wait for new deploy... %date% %time% %DELAY%s...
    ping -n %DELAY% > nul
    for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
    set arquivoBackup=e:\backup\%datetime%_LPK.iso
    %scripts%\wget %servidorOrigem%.md5 -O %arquivoDestino%.md5
    if exist %arquivoDestino%.md5 goto confirmedDownload
    goto waitForDeploy

    for /f %%i in ('type %arquivoDestino%.md5') do set HEADER_ISO_NOVA=%%i
    if "%HEADER_ISO_NOVA%"=="" goto invalidContent
    goto downloadConfirmedMD5
       echo [error] - Check The MD5 Checksum Of An ISO not confirmed, wait %DELAY%s...
    ping -n %DELAY% > nul
    goto waitForDeploy
    rem Verifica o cabecalho... se é igual...
    for /f %%i in ('%scripts%\ClusterUtil.exe -f%arquivoDestino% -thash') do set ISOAtual=%%i
    if "%HEADER_ISO_NOVA%"=="%ISOAtual%" goto duplicatedDownloadDetect

    %scripts%\wget %servidorOrigem% -O %arquivoDestino%.confirm
    if exist %arquivoDestino%.confirm goto downloadConfirmed  
    echo [error] - Download not confirmed, wait %DELAY%s...
    ping -n %DELAY% > nul
    goto waitForDeploy
    echo [error] - Duplicated download detected wait %DELAY%s...
    ping -n %DELAY% > nul
    goto waitForDeploy
    for /f %%i in ('%scripts%\ClusterUtil.exe -f%arquivoDestino%.confirm -thash') do set ISO_NOVA=%%i
    if "%ISO_NOVA%"=="%ISOAtual%" goto duplicatedDownloadDetect

    echo [ ok  ] - File confirmed, deploy starded...
    %windir%\System32\inetsrv\appcmd stop apppool /apppool.name:%applicationPoolName%
    powershell.exe "Dismount-DiskImage "%arquivoDestino%"
    move %arquivoDestino% %arquivoBackup%
    move %arquivoDestino%.confirm %arquivoDestino%
    powershell.exe "Mount-DiskImage "%arquivoDestino%""
    echo [ run  ] - Starting...
    %windir%\System32\inetsrv\appcmd start apppool /apppool.name:%applicationPoolName%
    echo [ wait  ] - %DELAY%s
    ping -n %DELAY% > nul
    goto waitForDeploy

Enable Lua Support

Enable or Disable  HAProxy...

echo "disable server bk_wrk/webapp-n1" | socat stdio /var/run/haproxy.sock
echo "enable server bk_wrk/webapp-n1" | socat stdio /var/run/haproxy.sock

 make TARGET=linux2628 ARCH=native USE_LUA=1 LUA_LIB=/usr/local/lib/lua/5.3/lib LUA_INC=/home/usr/lua-5.3.4/src

Postar um comentário