-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
31 lines (25 loc) · 917 Bytes
/
entrypoint.sh
File metadata and controls
31 lines (25 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Функция для ожидания доступности порта
wait_for_port() {
local host="$1"
local port="$2"
local timeout=10
local start_time=$(date +%s)
# Попробовать использовать nc, если установлен
local nc_command="nc"
type $nc_command >/dev/null 2>&1 || nc_command="ncat"
while ! $nc_command -z "$host" "$port" >/dev/null 2>&1; do
sleep 1
local current_time=$(date +%s)
local elapsed_time=$((current_time - start_time))
echo "trying to connecto to pg via $host:$port"
if [ $elapsed_time -ge $timeout ]; then
echo "Unable to connect to pg"
exit 1
fi
done
}
# Ожидание доступности порта PostgreSQL
wait_for_port "postgres" 5432
# Запуск Django-приложения
python manage.py runserver 0.0.0.0:8000