Warning: mkdir(): No space left on device in /var/www/tgoop/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/Linux_Club_nomer_1/--): Failed to open stream: No such file or directory in /var/www/tgoop/post.php on line 50
Linux Club@Linux_Club_nomer_1 P.1411
LINUX_CLUB_NOMER_1 Telegram 1411
🚀 Linux скрипт wait-for — дождаться TCP и запустить команду

Нужен простой «ожидатель» БД/сервиса в деплое/compose без nc и внешних утилит

#!/usr/bin/env bash
# wait-for host:port [timeout_sec] -- [cmd ...]
set -Eeuo pipefail
[[ $# -ge 1 ]] || { echo "usage: wait-for host:port [timeout] -- [cmd]"; exit 2; }
t="$1"; shift; to=30
[[ $# -ge 1 && "$1" =~ ^[0-9]+$ ]] && { to="$1"; shift; }
[[ "${1:-}" == "--" ]] && shift || true
h="${t%:*}"; p="${t##*:}"; end=$((SECONDS+to))
until { exec 3<>"/dev/tcp/$h/$p"; } 2>/dev/null; do
(( SECONDS>=end )) && { echo "timeout: $t"; exit 1; }
sleep 1
done
exec 3>&- 3<&-
echo "ready: $t"
(("$#" > 0)) && exec "$@"


Примеры:
🟢 дождаться Postgres и сразу миграции:
wait-for db:5432 30 -- alembic upgrade head

🟢 проверить сервис и просто выйти:
wait-for 127.0.0.1:8080 5


📌 Сохрани пост, чтобы не потерять.

#linux

🐧 Linux Club
Please open Telegram to view this post
VIEW IN TELEGRAM
6👍3😨2



tgoop.com/Linux_Club_nomer_1/1411
Create:
Last Update:

🚀 Linux скрипт wait-for — дождаться TCP и запустить команду

Нужен простой «ожидатель» БД/сервиса в деплое/compose без nc и внешних утилит

#!/usr/bin/env bash
# wait-for host:port [timeout_sec] -- [cmd ...]
set -Eeuo pipefail
[[ $# -ge 1 ]] || { echo "usage: wait-for host:port [timeout] -- [cmd]"; exit 2; }
t="$1"; shift; to=30
[[ $# -ge 1 && "$1" =~ ^[0-9]+$ ]] && { to="$1"; shift; }
[[ "${1:-}" == "--" ]] && shift || true
h="${t%:*}"; p="${t##*:}"; end=$((SECONDS+to))
until { exec 3<>"/dev/tcp/$h/$p"; } 2>/dev/null; do
(( SECONDS>=end )) && { echo "timeout: $t"; exit 1; }
sleep 1
done
exec 3>&- 3<&-
echo "ready: $t"
(("$#" > 0)) && exec "$@"


Примеры:
🟢 дождаться Postgres и сразу миграции:
wait-for db:5432 30 -- alembic upgrade head

🟢 проверить сервис и просто выйти:
wait-for 127.0.0.1:8080 5


📌 Сохрани пост, чтобы не потерять.

#linux

🐧 Linux Club

BY Linux Club


Share with your friend now:
tgoop.com/Linux_Club_nomer_1/1411

View MORE
Open in Telegram


Telegram News

Date: |

Unlimited number of subscribers per channel Ng, who had pleaded not guilty to all charges, had been detained for more than 20 months. His channel was said to have contained around 120 messages and photos that incited others to vandalise pro-government shops and commit criminal damage targeting police stations. Add the logo from your device. Adjust the visible area of your image. Congratulations! Now your Telegram channel has a face Click “Save”.! For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data. Add up to 50 administrators
from us


Telegram Linux Club
FROM American