Created
January 25, 2025 20:52
-
-
Save apetenchea/87503ac784e43286f1bad722cf9d0736 to your computer and use it in GitHub Desktop.
ArangoDB starter on windows
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
# Check inputs | |
if (-not $setup) { $setup = "cluster" } | |
if (-not $license) { $license = "enterprise" } | |
if (-not $version) { $version = "3.12" } | |
# Determine image name | |
if ($license -eq "community") { | |
$image_name = "arangodb" | |
} elseif ($license -eq "enterprise") { | |
$image_name = "enterprise" | |
} else { | |
Write-Host "Invalid argument. Please provide either 'community' or 'enterprise'." -ForegroundColor Red | |
exit 1 | |
} | |
# Validate version | |
if (-not $version) { | |
Write-Host "Error: Version is empty." -ForegroundColor Red | |
exit 1 | |
} | |
# Handle extra ports for cluster setup | |
$extra_ports = "" | |
if ($setup -eq "cluster") { | |
Write-Host "Starting cluster setup..." | |
$extra_ports = @("-p 8539:8539", "-p 8549:8549") | |
} elseif ($setup -eq "single") { | |
Write-Host "Starting single se33rver setup..." | |
} else { | |
Write-Host "Invalid argument. Please provide either 'single' or 'cluster'." -ForegroundColor Red | |
exit 1 | |
} | |
# Build Docker arguments | |
$dockerArgs = @( | |
"-d", | |
"--name", "arango", | |
"-p", "8528:8528", | |
"-p", "8529:8529" | |
) | |
if ($extra_ports -ne "") { | |
$dockerArgs += $extra_ports.Split(" ") | |
} | |
$dockerArgs += @( | |
"-v", "D:/arangodb/python-arango-async/tests/static:/tests/static", | |
"-v", "C:/Temp:/tmp", | |
"arangodb/${image_name}:${version}", | |
"/bin/sh", "-c", "arangodb --configuration=/tests/static/$setup-$version.conf" | |
) | |
# Debugging: Print the constructed Docker command | |
Write-Host "Docker command: docker run $($dockerArgs -join ' ')" | |
# Run Docker container | |
docker run @dockerArgs | |
# Wait for the server to be ready | |
Write-Host "Waiting for the ArangoDB server to start..." | |
$retryCount = 0 | |
$maxRetries = 120 | |
$serverReady = $false | |
while (-not $serverReady -and $retryCount -lt $maxRetries) { | |
Start-Sleep -Seconds 1 | |
$retryCount++ | |
try { | |
$response = Invoke-RestMethod -Uri "http://localhost:8528/version" -ErrorAction Stop | |
if ($response) { | |
$serverReady = $true | |
} | |
} catch { | |
Write-Host "Waiting for the server... ($retryCount/$maxRetries)" | |
} | |
} | |
if ($serverReady) { | |
Write-Host "ArangoDB server is up and running!" -ForegroundColor Green | |
exit 0 | |
} else { | |
Write-Host "ERROR: ArangoDB server did not start within the timeout period." -ForegroundColor Red | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment