Last active
September 18, 2017 08:50
-
-
Save IlyaFinkelshteyn/9e009683bd0d7270391a05dc3b9dc381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "Installing DynamoDb..." -ForegroundColor Cyan -NoNewline | |
mkdir C:\DynamoDb | |
$dnynamoDbPath = "C:\DynamoDb" | |
$zipPath = "$($env:TEMP)\dynamodb_local_latest.zip" | |
(New-Object Net.WebClient).DownloadFile('https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip', $zipPath) | |
7z x $zipPath -y -o"$dnynamoDbPath" | Out-Null | |
del $zipPath | |
#http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html | |
cd $dnynamoDbPath | |
Set-Content -Value "java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb" -Path .\startDynamoDb.cmd | |
Start-Process -FilePath .\startDynamoDb.cmd | |
cd $env:appveyor_build_folder | |
$attempt = 0 | |
$max = 3 | |
while(!$client.Connected -and $attempt -lt $max) { | |
try { | |
$client = New-Object System.Net.Sockets.TcpClient([System.Net.Sockets.AddressFamily]::InterNetwork) | |
$attempt++; $client.Connect("127.0.0.1", 8000); write-host "DynamoDB started" | |
} | |
catch { | |
if($attempt -eq $max) { | |
write-host "DynamoDB was not started"; $client.Close(); return | |
} | |
[int]$sleepTime = 5*$attempt | |
write-host "DynamoDB is not started. Retry after $sleepTime seconds..." | |
sleep $sleepTime; | |
$client.Close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment