fix: stabilize im server startup and p2p topic scans
This commit is contained in:
@@ -41,7 +41,7 @@ ENV RESET_DB=false
|
||||
ENV UPGRADE_DB=false
|
||||
|
||||
# Option to skip DB initialization when it's missing.
|
||||
ENV NO_DB_INIT=false
|
||||
ENV NO_DB_INIT=true
|
||||
|
||||
# Load sample data to database from data.json.
|
||||
ARG SAMPLE_DATA=data.json
|
||||
@@ -130,7 +130,7 @@ ENV TNPG_ORG=
|
||||
|
||||
# Video calls configuration.
|
||||
ENV WEBRTC_ENABLED=false
|
||||
ENV ICE_SERVERS_FILE=
|
||||
ENV ICE_SERVERS_FILE=/opt/tinode/ice-servers.json
|
||||
|
||||
# Use the target db by default.
|
||||
# When TARGET_DB is "alldbs", it is the user's responsibility
|
||||
@@ -153,6 +153,7 @@ WORKDIR /opt/tinode
|
||||
# Copy config template to the container.
|
||||
COPY config.template .
|
||||
COPY entrypoint.sh .
|
||||
COPY ice-servers.json .
|
||||
|
||||
# Get the desired Tinode build.
|
||||
ADD https://github.com/tinode/chat/releases/download/v$BINVERS/tinode-$TARGET_DB.linux-amd64.tar.gz .
|
||||
|
||||
@@ -27,7 +27,7 @@ LABEL name="ImServer"
|
||||
ENV WAIT_FOR=
|
||||
ENV RESET_DB=false
|
||||
ENV UPGRADE_DB=false
|
||||
ENV NO_DB_INIT=false
|
||||
ENV NO_DB_INIT=true
|
||||
# Empty by default: do not load Tinode's canned demo users into a real deployment.
|
||||
# Override explicitly if sample data is ever wanted.
|
||||
ENV SAMPLE_DATA=
|
||||
@@ -51,6 +51,7 @@ ENV FCM_PUSH_ENABLED=false
|
||||
ENV FCM_INCLUDE_ANDROID_NOTIFICATION=true
|
||||
ENV TNPG_PUSH_ENABLED=false
|
||||
ENV WEBRTC_ENABLED=false
|
||||
ENV ICE_SERVERS_FILE=/opt/tinode/ice-servers.json
|
||||
ENV SERVER_STATUS_PATH=''
|
||||
ENV ACC_GC_ENABLED=false
|
||||
ENV PLUGIN_PYTHON_CHAT_BOT_ENABLED=false
|
||||
@@ -68,6 +69,7 @@ WORKDIR /opt/tinode
|
||||
|
||||
COPY docker/tinode/config.template .
|
||||
COPY docker/tinode/entrypoint.sh .
|
||||
COPY docker/tinode/ice-servers.json .
|
||||
COPY tinode-db/credentials.sh .
|
||||
COPY server/templ ./templ
|
||||
COPY --from=build /out/tinode .
|
||||
|
||||
+52
-20
@@ -113,27 +113,59 @@ if [ ! -z "$WAIT_FOR" ] ; then
|
||||
until nc -z -v -w5 ${DB[0]} ${DB[1]}; do echo "waiting for ${WAIT_FOR}..."; sleep 3; done
|
||||
fi
|
||||
|
||||
# Initialize the database if it has not been initialized yet or if data reset/upgrade has been requested.
|
||||
init_stdout=./init-db-stdout.txt
|
||||
./init-db \
|
||||
--reset=${RESET_DB} \
|
||||
--upgrade=${UPGRADE_DB} \
|
||||
--config=${CONFIG} \
|
||||
--data=${SAMPLE_DATA} \
|
||||
--no_init=${NO_DB_INIT} \
|
||||
1>${init_stdout}
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "./init-db failed. Quitting."
|
||||
exit 1
|
||||
fi
|
||||
run_with_retries() {
|
||||
local name="$1"
|
||||
shift
|
||||
local attempts="${STARTUP_RETRY_ATTEMPTS:-10}"
|
||||
local delay="${STARTUP_RETRY_DELAY_SECONDS:-3}"
|
||||
local i=1
|
||||
while [ "$i" -le "$attempts" ]; do
|
||||
"$@"
|
||||
local status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
return 0
|
||||
fi
|
||||
echo "$name failed with status $status (attempt $i/$attempts)."
|
||||
if [ "$i" -eq "$attempts" ]; then
|
||||
return "$status"
|
||||
fi
|
||||
sleep "$delay"
|
||||
i=$((i + 1))
|
||||
done
|
||||
}
|
||||
|
||||
# Create/upgrade the hotgo tenant registry and the workbench/org/meetings/
|
||||
# reports/mailbox/etc. tables that init-db above does not manage. Idempotent
|
||||
# (IF NOT EXISTS / ON DUPLICATE KEY UPDATE throughout), safe to run every start.
|
||||
IM_MYSQL_DSN="${MYSQL_DSN}" ./apply-hotgo-tenant-db
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "./apply-hotgo-tenant-db failed. Quitting."
|
||||
exit 1
|
||||
init_db_once() {
|
||||
./init-db \
|
||||
--reset=${RESET_DB} \
|
||||
--upgrade=${UPGRADE_DB} \
|
||||
--config=${CONFIG} \
|
||||
--data=${SAMPLE_DATA} \
|
||||
--no_init=${NO_DB_INIT} \
|
||||
1>${init_stdout}
|
||||
}
|
||||
|
||||
apply_hotgo_tenant_db_once() {
|
||||
IM_MYSQL_DSN="${MYSQL_DSN}" ./apply-hotgo-tenant-db
|
||||
}
|
||||
|
||||
init_stdout=./init-db-stdout.txt
|
||||
if [ "$NO_DB_INIT" = "true" ] ; then
|
||||
echo "NO_DB_INIT=true: skipping init-db and apply-hotgo-tenant-db."
|
||||
else
|
||||
# Initialize the database if it has not been initialized yet or if data reset/upgrade has been requested.
|
||||
run_with_retries "init-db" init_db_once
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "./init-db failed. Quitting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create/upgrade the hotgo tenant registry and the workbench/org/meetings/
|
||||
# reports/mailbox/etc. tables that init-db above does not manage.
|
||||
run_with_retries "apply-hotgo-tenant-db" apply_hotgo_tenant_db_once
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "./apply-hotgo-tenant-db failed. Quitting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If sample data was provided, try to find Tino password.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
[
|
||||
{
|
||||
"urls": ["stun:stun.l.google.com:19302"]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user