start_announcement.sh
1.87 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
ENV_FILE="$SCRIPT_DIR/../.env.sh"
if [ -f "$ENV_FILE" ]; then
echo "Loading configuration from $ENV_FILE"
source "$ENV_FILE"
else
echo "Error: Configuration file not found at $ENV_FILE"
exit 1
fi
if [ -z "$LOCAL_FRONTEND_PORT" ]; then
echo "Error: LOCAL_FRONTEND_PORT is not set in .env.sh"
exit 1
fi
echo "=================================================="
echo "Starting Maintenance Announcement"
echo "Target Port: $LOCAL_FRONTEND_PORT"
echo "Public Port: ${PUBLIC_FRONTEND_PORT:-Unknown}"
echo "=================================================="
APP_NAME="${FRONTEND_NAME:-z-image-frontend}"
if command -v pm2 &> /dev/null; then
echo "Stopping main frontend application ($APP_NAME)..."
pm2 stop "$APP_NAME" 2>/dev/null || echo "Main frontend was not running or could not be stopped."
MAINTENANCE_APP_NAME="maintenance-announcement-beta"
echo "Starting announcement page on port $LOCAL_FRONTEND_PORT..."
if command -v python3 &> /dev/null; then
pm2 delete "$MAINTENANCE_APP_NAME" 2>/dev/null || true
pm2 start "python3 -m http.server $LOCAL_FRONTEND_PORT" \
--name "$MAINTENANCE_APP_NAME" \
--cwd "$SCRIPT_DIR" \
--watch
echo "Maintenance announcement started."
pm2 list
else
echo "Error: python3 is not available. Please install python3 to run the simple http server."
exit 1
fi
else
echo "Error: pm2 is not installed or not in PATH."
exit 1
fi
echo "=================================================="
echo "Maintenance page should be visible at:"
echo "http://localhost:$LOCAL_FRONTEND_PORT"
if [ ! -z "$PUBLIC_IP" ] && [ ! -z "$PUBLIC_FRONTEND_PORT" ]; then
echo "http://$PUBLIC_IP:$PUBLIC_FRONTEND_PORT"
fi
echo "=================================================="