-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.sh
More file actions
executable file
·90 lines (69 loc) · 2.19 KB
/
startup.sh
File metadata and controls
executable file
·90 lines (69 loc) · 2.19 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# AsylumSite Startup Script
# This script starts the Django development server and background scheduler
echo "🚀 Starting AsylumSite..."
# --- Kill existing processes ---
echo "Stopping existing processes..."
pkill -f "gunicorn" 2>/dev/null
pkill -f "python3" 2>/dev/null
# Wait a moment for processes to stop
sleep 2
# --- Git operations ---
echo "Updating from git..."
git pull
# Check if git pull was successful
if [ $? -ne 0 ]; then
echo "Git pull failed. Exiting startup script." >&2
exit 1
fi
echo "Git pull successful"
# --- Set paths ---
PYTHON_PATH="python3"
MANAGE_PY="./manage.py"
# --- Apply migrations ---
echo "Applying database migrations..."
"$PYTHON_PATH" "$MANAGE_PY" migrate
if [ $? -ne 0 ]; then
echo "Migration failed. Exiting startup script." >&2
exit 1
fi
echo "Migrations applied successfully"
# --- Collect static files ---
echo "Collecting static files..."
"$PYTHON_PATH" "$MANAGE_PY" collectstatic --noinput
if [ $? -ne 0 ]; then
echo "Static file collection failed. Exiting startup script." >&2
exit 1
fi
echo "Static files collected"
# --- Start background scheduler ---
echo "Starting background scheduler..."
nohup "$PYTHON_PATH" "$MANAGE_PY" start_updates >> scheduler.log 2>&1 &
# Get the PID of the background scheduler
SCHEDULER_PID=$!
echo "Background scheduler started with PID: $SCHEDULER_PID"
# Wait a moment for scheduler to initialize
sleep 3
# --- Start Django development server ---
echo "Starting Django development server..."
nohup "$PYTHON_PATH" "$MANAGE_PY" runserver 0.0.0.0:8005 >> django.log 2>&1 &
# Get the PID of the Django server
DJANGO_PID=$!
echo "Django server started with PID: $DJANGO_PID"
# --- Display status ---
echo ""
echo "AsylumSite startup complete!"
echo "=================================="
echo "Services Status:"
echo "• Django Server: PID $DJANGO_PID (http://localhost:8005)"
echo "• Background Scheduler: PID $SCHEDULER_PID"
echo ""
echo "Scheduler Configuration:"
echo "• Pending tasks: Every 5 minutes"
echo "• Modpack updates: Every 30 minutes"
echo ""
echo "Log Files:"
echo "• Django server: django.log"
echo "• Background scheduler: scheduler.log"
echo ""
echo "----------------------------------"