Implement shared Caddy setup with initializing and unavailable pages for various apps
- Refactor domain scripts for Ghost, Gitea, Jellyfin, Metabase, n8n, NocoDB, Open WebUI, OpenClaw, PicoClaw, Plausible, Signoz, Uptime Kuma, and Vaultwarden to utilize a common Caddy setup script. - Introduce `caddy-setup.sh` for managing Caddy configurations and handling app initialization states. - Create `initializing.html` and `unavailable.html` pages to provide user feedback during app deployment and downtime. - Update domain handling logic to ensure seamless transitions between initializing and operational states. - Enhance user experience by providing visual indicators for app status during setup and maintenance.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
APP_NAME="erpnext"
|
||||
APP_DIR="/var/excloud/apps"
|
||||
APP_UPSTREAM_PORT="${EXC_APP_UPSTREAM_PORT:-8080}"
|
||||
|
||||
DOMAIN="${1}"
|
||||
|
||||
if [ -z "${DOMAIN}" ]; then
|
||||
@@ -9,13 +12,17 @@ if [ -z "${DOMAIN}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > /etc/caddy/Caddyfile <<EOF
|
||||
https://${DOMAIN} {
|
||||
reverse_proxy 127.0.0.1:${APP_UPSTREAM_PORT}
|
||||
}
|
||||
EOF
|
||||
ERPNEXT_DIR="${APP_DIR}/${APP_NAME}"
|
||||
COMPOSE_FILE="${ERPNEXT_DIR}/pwd.yml"
|
||||
|
||||
echo "Caddyfile updated"
|
||||
source /var/excloud/scripts/caddy-setup.sh
|
||||
|
||||
systemctl enable caddy
|
||||
systemctl reload caddy
|
||||
if is_app_ready "$ERPNEXT_DIR"; then
|
||||
# Update ERPNext site host_name for correct URLs in emails/redirects
|
||||
docker compose -f "${COMPOSE_FILE}" exec -T backend bench --site frontend set-config host_name "https://${DOMAIN}"
|
||||
docker compose -f "${COMPOSE_FILE}" restart backend frontend websocket
|
||||
switch_domain "$DOMAIN" "$APP_UPSTREAM_PORT" "$ERPNEXT_DIR"
|
||||
else
|
||||
setup_initializing_page "$DOMAIN" "$APP_NAME" "$ERPNEXT_DIR"
|
||||
wait_and_switch_to_proxy "$DOMAIN" "$APP_UPSTREAM_PORT" "$ERPNEXT_DIR" &
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user