init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
@echo off
|
||||
setlocal EnableExtensions EnableDelayedExpansion
|
||||
|
||||
if "%TARGET_INSTANCE_ID%"=="" exit /b 2
|
||||
cd /d "%~dp0\.."
|
||||
if not defined ENV_FILE set "ENV_FILE=.env"
|
||||
|
||||
set "TARGET_CONTAINER="
|
||||
set /a MATCHES=0
|
||||
for /f "usebackq delims=" %%C in (`docker compose --env-file "%ENV_FILE%" ps -q api`) do (
|
||||
set "CONTAINER_ID=%%C"
|
||||
set "SHORT_ID=!CONTAINER_ID:~0,12!"
|
||||
set "HOSTNAME_VALUE="
|
||||
for /f "usebackq delims=" %%H in (`docker inspect --format "{{.Config.Hostname}}" %%C`) do set "HOSTNAME_VALUE=%%H"
|
||||
if "!HOSTNAME_VALUE!"=="%TARGET_INSTANCE_ID%" (
|
||||
set "TARGET_CONTAINER=%%C"
|
||||
set /a MATCHES+=1
|
||||
) else if "!SHORT_ID!"=="%TARGET_INSTANCE_ID%" (
|
||||
set "TARGET_CONTAINER=%%C"
|
||||
set /a MATCHES+=1
|
||||
)
|
||||
)
|
||||
|
||||
if not "!MATCHES!"=="1" exit /b 2
|
||||
docker stop --time 5 "!TARGET_CONTAINER!" >nul
|
||||
exit /b %ERRORLEVEL%
|
||||
Reference in New Issue
Block a user