Skip to content

Commit

Permalink
[windows] use of PortQry to avoid curl
Browse files Browse the repository at this point in the history
  • Loading branch information
bamthomas committed Feb 13, 2019
1 parent 25a750a commit 391a8c3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.exe
.idea
mac/dist
windows/dist
Expand Down
Binary file added windows/PortQry.exe
Binary file not shown.
65 changes: 62 additions & 3 deletions windows/datashare.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,64 @@
@echo off

set CURRENT_RUNNING_BATCH_PATH=%~dp0
PowerShell.exe -Command "& '%CURRENT_RUNNING_BATCH_PATH%\datashare.ps1'"
PAUSE
docker info 2>NUL

if ERRORLEVEL 1 (
echo docker is not running, launching it
start "" "\Program Files\Docker\Docker\Docker for Windows.exe"
call :wait_docker_is_up
)

set datashare_id=
for /f "delims=" %%a in ('docker-compose -p datashare ps -q datashare') do @set datashare_id=%%a
set datashare_status=
if [%datashare_id] == [] (
for /f "delims=" %%a in ('docker inspect %datashare_id% -f "{{.State.Status}}"') do @set datashare_status=%%a
)
set mem_size=
for /f "skip=1" %%a in ('wmic os get totalvirtualmemorysize') do (
set mem_size=%%a
goto :done
)
:done
set /a mem_allocated=mem_size/(2*1024)
set DS_JAVA_OPTS=-Xmx%mem_allocated%m

if "%datashare_status%"=="running" (
docker-compose -p datashare restart datashare
) else (
docker-compose -p datashare up -d
)

call :wait_idx_is_up

if not ERRORLEVEL 1 (
start "" http://localhost:8080
)

exit /B %ERRORLEVEL%

:wait_docker_is_up
echo|set /p="waiting for docker to be up"
for /l %%x in (1, 1, 60) do (
docker info 2>NUL
if not ERRORLEVEL 1 (
echo OK
exit /B 0
)
echo|set /p="."
timeout /t 1 /nobreak > NUL
)

:wait_idx_is_up
echo|set /p="waiting for datashare to be up"
for /l %%x in (1, 1, 60) do (
timeout /t 1 /nobreak >NUL
"%~dp0/PortQry.exe" -n "localhost" -e 8080 >NUL 2>NUL
if not ERRORLEVEL 1 (
echo OK
exit /B 0
)
echo|set /p="."
)
echo KO
exit /B %ERRORLEVEL%
2 changes: 1 addition & 1 deletion windows/installDatashare.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ Function InstallDatashare
exch $R0
SetOutPath "$INSTDIR"
file "datashare.ico"
File "datashare.ps1"
File "datashare.bat"
File "PortQry.exe"
File /oname=docker-compose.yml "dist/docker-compose.yml"

# Start Menu
Expand Down

0 comments on commit 391a8c3

Please sign in to comment.