-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmanage-app.sh
More file actions
executable file
·69 lines (67 loc) · 1.99 KB
/
manage-app.sh
File metadata and controls
executable file
·69 lines (67 loc) · 1.99 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
#!/bin/bash
# Management script for Django application
PROJECT_PATH="/home/ubuntu/github_management/RB"
case "$1" in
start)
echo "Starting application..."
sudo systemctl start gunicorn
sudo systemctl start celery
sudo systemctl start celery-beat
sudo systemctl start nginx
echo "Application started"
;;
stop)
echo "Stopping application..."
sudo systemctl stop gunicorn
sudo systemctl stop celery
sudo systemctl stop celery-beat
sudo systemctl stop nginx
echo "Application stopped"
;;
restart)
echo "Restarting application..."
sudo systemctl restart gunicorn
sudo systemctl restart celery
sudo systemctl restart celery-beat
sudo systemctl restart nginx
echo "Application restarted"
;;
status)
echo "=== Gunicorn Status ==="
sudo systemctl status gunicorn --no-pager
echo ""
echo "=== Celery Status ==="
sudo systemctl status celery --no-pager
echo ""
echo "=== Celery Beat Status ==="
sudo systemctl status celery-beat --no-pager
echo ""
echo "=== Nginx Status ==="
sudo systemctl status nginx --no-pager
;;
logs)
echo "=== Gunicorn Logs ==="
sudo journalctl -u gunicorn -n 50 --no-pager
echo ""
echo "=== Celery Logs ==="
sudo journalctl -u celery -n 50 --no-pager
;;
update)
echo "Updating application..."
cd $PROJECT_PATH
git pull
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py collectstatic --noinput
deactivate
sudo systemctl restart gunicorn
sudo systemctl restart celery
sudo systemctl restart celery-beat
echo "Application updated"
;;
*)
echo "Usage: $0 {start|stop|restart|status|logs|update}"
exit 1
;;
esac