[
    {
        "UpdateStageName": "Run MongoDB Server",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd mongodb && export PATH=\\\"{{$FullBaseDir}}mongodb/bin:{{$FullBaseDir}}mongosh/bin:$PATH\\\"; export GLIBC_TUNABLES=glibc.pthread.rseq=0; mongosh/bin/mongosh --host 127.0.0.1 --port {{$ServerPort}} --quiet --eval \\\"db.runCommand({ ping: 1 })\\\" >/dev/null 2>&1 && exit 0 || mongodb/bin/mongod {{CustomServerOptions}} --auth --config {{$FullBaseDir}}mongod.conf --dbpath {{$FullBaseDir}}data --port {{$ServerPort}} --bind_ip 0.0.0.0 --unixSocketPrefix {{$FullBaseDir}}run --logpath {{$FullBaseDir}}log/mongodb/mongod.log --logappend --logRotate rename --fork\"",
        "RunInBackground": true,
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Run MongoDB Server",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "powershell.exe",
        "UpdateSourceArgs": "-NoProfile -Command \"Set-Location -Path 'mongodb'; $env:PATH = \\\"{{$FullBaseDir}}mongodb\\bin;{{$FullBaseDir}}mongosh\\bin;\\\" + $env:PATH; & mongosh/bin/mongosh.exe --host 127.0.0.1 --port {{$ServerPort}} --quiet --eval 'db.runCommand({ ping: 1 })' *> $null; if ($LASTEXITCODE -eq 0) { exit 0 } else { & mongodb/bin/mongod.exe {{CustomServerOptions}} --auth --config {{$FullBaseDir}}mongod.conf --dbpath \\\"{{$FullBaseDir}}data\\\" --port {{$ServerPort}} --bind_ip 0.0.0.0 --logpath \\\"{{$FullBaseDir}}log\\mongodb\\mongod.log\\\" --logappend --logRotate rename }\"",
        "RunInBackground": true,
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Wait For Server Start",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd mongodb && export PATH=\\\"{{$FullBaseDir}}mongosh/bin:$PATH\\\"; timeout=60; while ((timeout--)); do mongosh/bin/mongosh --host 127.0.0.1 --port {{$ServerPort}} --quiet --eval \\\"db.runCommand({ ping: 1 })\\\" >/dev/null 2>&1 && break || sleep 1; done; if ((timeout < 0)); then echo \\\"MongoDB server failed to start. Aborting\\\"; exit 1; fi\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Wait For Server Start",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "powershell.exe",
        "UpdateSourceArgs": "-NoProfile -Command \"Set-Location -Path 'mongodb'; $env:PATH = \\\"{{$FullBaseDir}}mongosh\\bin;\\\" + $env:PATH; for ($i = 0; $i -lt 60; $i++) { & mongosh/bin/mongosh.exe --host 127.0.0.1 --port {{$ServerPort}} --quiet --eval 'db.runCommand({ ping: 1 })' *> $null; if ($LASTEXITCODE -eq 0) { break }; Start-Sleep -Seconds 1 }; if ($i -eq 60) { Write-Output 'MongoDB server failed to start. Aborting'; exit 1 }\"",
        "SkipOnFailure": false
    }
]