mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
win: run mongo script improvements
This commit is contained in:
parent
68e5e7df21
commit
da23775c25
1 changed files with 32 additions and 29 deletions
|
|
@ -37,37 +37,37 @@ function Exit-WithCode($exitcode) {
|
|||
|
||||
|
||||
function Find-Mongo {
|
||||
Write-Host ">>> " -NoNewLine -ForegroundColor Green
|
||||
Write-Host "Detecting MongoDB ... " -NoNewline
|
||||
if (-not (Get-Command "mongod" -ErrorAction SilentlyContinue)) {
|
||||
if(Test-Path 'C:\Program Files\MongoDB\Server\*\bin\mongod.exe' -PathType Leaf) {
|
||||
# we have mongo server installed on standard Windows location
|
||||
# so we can inject it to the PATH. We'll use latest version available.
|
||||
$mongoVersions = Get-ChildItem -Directory 'C:\Program Files\MongoDB\Server' | Sort-Object -Property {$_.Name -as [int]}
|
||||
if(Test-Path "$($mongoVersions[-1])\bin\mongod.exe" -PathType Leaf) {
|
||||
$env:PATH="$($env:PATH);$($mongoVersions[-1])\bin\"
|
||||
Write-Host "OK" -ForegroundColor Green
|
||||
Write-Host " - auto-added from [ " -NoNewline
|
||||
Write-Host "$($mongoVersions[-1])\bin\" -NoNewLine -ForegroundColor Cyan
|
||||
Write-Host " ]"
|
||||
} else {
|
||||
Write-Host "FAILED " -NoNewLine -ForegroundColor Red
|
||||
Write-Host "MongoDB not detected" -ForegroundColor Yellow
|
||||
Write-Host "Tried to find it on standard location " -NoNewline -ForegroundColor Gray
|
||||
Write-Host " [ " -NoNewline -ForegroundColor Cyan
|
||||
Write-Host "$($mongoVersions[-1])\bin\" -NoNewline -ForegroundColor White
|
||||
Write-Host " ] " -NonNewLine -ForegroundColor Cyan
|
||||
Write-Host "but failed." -ForegroundColor Gray
|
||||
Exit-WithCode 1
|
||||
}
|
||||
$defaultPath = "C:\Program Files\MongoDB\Server"
|
||||
Write-Host ">>> " -NoNewLine -ForegroundColor Green
|
||||
Write-Host "Detecting MongoDB ... " -NoNewline
|
||||
if (-not (Get-Command "mongod" -ErrorAction SilentlyContinue)) {
|
||||
if(Test-Path "$($defaultPath)\*\bin\mongod.exe" -PathType Leaf) {
|
||||
# we have mongo server installed on standard Windows location
|
||||
# so we can inject it to the PATH. We'll use latest version available.
|
||||
$mongoVersions = Get-ChildItem -Directory 'C:\Program Files\MongoDB\Server' | Sort-Object -Property {$_.Name -as [int]}
|
||||
if(Test-Path "$($defaultPath)\$($mongoVersions[-1])\bin\mongod.exe" -PathType Leaf) {
|
||||
$env:PATH="$($env:PATH);$($defaultPath)\$($mongoVersions[-1])\bin\"
|
||||
Write-Host "OK" -ForegroundColor Green
|
||||
Write-Host " - auto-added from [ " -NoNewline
|
||||
Write-Host "$($defaultPath)\$($mongoVersions[-1])\bin\" -NoNewLine -ForegroundColor Cyan
|
||||
Write-Host " ]"
|
||||
} else {
|
||||
Write-Host "FAILED " -NoNewLine -ForegroundColor Red
|
||||
Write-Host "MongoDB not detected" -ForegroundColor Yellow
|
||||
Write-Host "Tried to find it on standard location " -NoNewline -ForegroundColor Gray
|
||||
Write-Host " [ " -NoNewline -ForegroundColor Cyan
|
||||
Write-Host "$($defaultPath)\$($mongoVersions[-1])\bin\" -NoNewline -ForegroundColor White
|
||||
Write-Host " ] " -NonNewLine -ForegroundColor Cyan
|
||||
Write-Host "but failed." -ForegroundColor Gray
|
||||
Exit-WithCode 1
|
||||
}
|
||||
} else {
|
||||
Write-Host "FAILED " -NoNewLine -ForegroundColor Red
|
||||
Write-Host "MongoDB not detected in PATH" -ForegroundColor Yellow
|
||||
Exit-WithCode 1
|
||||
Write-Host "FAILED " -NoNewLine -ForegroundColor Red
|
||||
Write-Host "MongoDB not detected in PATH" -ForegroundColor Yellow
|
||||
Exit-WithCode 1
|
||||
}
|
||||
|
||||
} else {
|
||||
Write-Host "OK" -ForegroundColor Green
|
||||
Write-Host "OK" -ForegroundColor Green
|
||||
}
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
|
@ -90,4 +90,7 @@ $dbpath = (Get-Item $pype_root).parent.FullName + "\mongo_db_data"
|
|||
|
||||
Find-Mongo
|
||||
$mongo = Get-Command "mongod" | Select-Object -ExpandProperty Definition
|
||||
Start-Process -FilePath $mongo "--dbpath $($dbpath) --port $($port)"
|
||||
$process = Start-Process -FilePath $mongo "--dbpath $($dbpath) --port $($port)" -PassThru -NoNewWindow -Wait
|
||||
$process.WaitForExit()
|
||||
Start-Process PowerShell -NoNewWindow -Wait
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue