-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Max 🍉
committed
Feb 11, 2024
1 parent
9641a61
commit 8051924
Showing
8 changed files
with
116 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,90 @@ | ||
#!/bin/bash | ||
|
||
#!/bin/bash | ||
|
||
THREADS=${THREADS:-100} | ||
LOG_LEVEL=${LOG_LEVEL:-info} | ||
|
||
# Function to display help message | ||
show_help() { | ||
echo "Chaos Control" | ||
echo "Usage: chaosctl [command]" | ||
echo "Commands:" | ||
echo " migrate Run database migrations" | ||
echo " createsuperuser Create a superuser" | ||
echo " staticfiles Collect static files" | ||
echo " web [--init] Launch the web application, add --init to migrate" | ||
echo " worker Launch the bacground worker" | ||
echo " beat Launch the beat timer" | ||
} | ||
|
||
# Check if at least one argument is provided | ||
if [ $# -lt 1 ]; then | ||
echo "Error: No command provided." | ||
show_help | ||
exit 1 | ||
fi | ||
|
||
createsuperuser() { | ||
echo -e "\n[+]Creating a superuser for environment: $3..." | ||
python /opt/chaos.corp/tpng/manage.py createsuperuser --noinput; | ||
} | ||
|
||
migrate() { | ||
echo -e "\n[+]Running database migrations..." | ||
python /opt/chaos.corp/tpng/manage.py migrate | ||
} | ||
|
||
collect_static() { | ||
echo -e "\n[+]Collecting static files..." | ||
python /opt/chaos.corp/tpng/manage.py collectstatic --noinput | ||
} | ||
|
||
start_gunicorn() { | ||
echo -e "\n[+]Starting gunicorn..." | ||
gunicorn -c trunkplayer_ng/gunicorn.conf.py | ||
} | ||
|
||
start_beat() { | ||
echo -e "\n[+]Starting Celery beat..." | ||
celery -A trunkplayer_ng beat -l $LOG_LEVEL | ||
} | ||
|
||
start_worker() { | ||
echo -e "\n[+]Starting celerry worker $THREADS:THREADS..." | ||
celery -A trunkplayer_ng worker -l $LOG_LEVEL --pool gevent --concurrency $THREADS -E -Q default,transmission_forwarding,radio_refrence,radio_alerts,transmission_ingest,tranmission_push | ||
} | ||
|
||
# Process commands | ||
case "$1" in | ||
web) | ||
if [[ "$2" == "--init" ]]; then | ||
migrate | ||
createsuperuser | ||
collect_static | ||
start_gunicorn | ||
else | ||
start_gunicorn | ||
fi | ||
;; | ||
|
||
beat) | ||
start_beat | ||
;; | ||
|
||
worker) | ||
start_worker | ||
;; | ||
|
||
help) | ||
show_help | ||
exit 0 | ||
;; | ||
|
||
*) | ||
echo "Error: Unknown command '$1'." | ||
show_help | ||
exit 1 | ||
;; | ||
esac | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters