Wait for UCE service readiness

This commit is contained in:
root 2026-07-17 02:09:16 +00:00
parent 672e5b66ef
commit b0d475e777
3 changed files with 22 additions and 0 deletions

View File

@ -13,6 +13,7 @@ StateDirectory=uce
CacheDirectory=uce
ExecStartPre=/usr/bin/mkdir -p /var/cache/uce/work /var/lib/uce/uploads /var/lib/uce/sessions
ExecStart=/usr/lib/uce/bin/uce_fastcgi.linux.bin
ExecStartPost=/usr/bin/bash /usr/lib/uce/scripts/systemd/wait-ready.sh
Restart=always
RestartSec=2
TimeoutStopSec=30

View File

@ -14,6 +14,7 @@ CacheDirectory=uce
ExecStartPre=/usr/bin/mkdir -p /var/cache/uce/work /var/lib/uce/uploads /var/lib/uce/sessions
ExecStartPre=/usr/bin/bash /Code/uce.openfu.com/uce/scripts/build_linux.sh
ExecStart=/Code/uce.openfu.com/uce/bin/uce_fastcgi.linux.bin
ExecStartPost=/usr/bin/bash /Code/uce.openfu.com/uce/scripts/systemd/wait-ready.sh
Restart=always
RestartSec=2
TimeoutStopSec=30

20
scripts/systemd/wait-ready.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
socket_path="/run/uce/cli.sock"
if [[ -r /etc/uce/settings.cfg ]]; then
configured_socket=$(awk -F= '/^[[:space:]]*CLI_SOCKET_PATH[[:space:]]*=/ {gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2); print $2; exit}' /etc/uce/settings.cfg)
if [[ -n "${configured_socket:-}" ]]; then
socket_path="$configured_socket"
fi
fi
for ((attempt = 0; attempt < 200; attempt++)); do
if [[ -S "$socket_path" ]]; then
exit 0
fi
sleep 0.05
done
echo "UCE CLI socket did not become ready: $socket_path" >&2
exit 1