@@ -100,12 +100,14 @@ GIT_INSTALL_DIR="$EXTRACT_DIR/${APP_NAME}-git"
100
100
LOG_DIR=" $USER_HOME /logs"
101
101
LOG_FILE=" $LOG_DIR /systemguard-installer.log"
102
102
BACKUP_DIR=" $USER_HOME /.systemguard_backup"
103
- EXECUTABLE=" /usr/local/bin/systemguard-installer"
103
+ EXECUTABLE_APP_NAME=" systemguard-installer"
104
+ EXECUTABLE=" /usr/local/bin/$EXECUTABLE_APP_NAME "
104
105
105
106
# File paths related to the application
106
107
LOCUST_FILE=" $EXTRACT_DIR /${APP_NAME} -*/src/scripts/locustfile.py"
107
108
HOST_URL=" http://localhost:5050"
108
109
INSTALLER_SCRIPT=' setup.sh'
110
+ FLASK_LOG_FILE=" $USER_HOME /logs/systemguard_flask.log"
109
111
110
112
# Number of backups to keep
111
113
NUM_OF_BACKUP=5
@@ -203,7 +205,7 @@ add_cron_job() {
203
205
204
206
rm " $temp_cron "
205
207
log " INFO" " Cron job added successfully"
206
- log $cron_job
208
+ # log $cron_job
207
209
}
208
210
209
211
# Function to clean up all backups
@@ -511,7 +513,7 @@ load_test() {
511
513
# Check if Locust is installed
512
514
if ! command -v locust & > /dev/null
513
515
then
514
- log " Locust is not installed. Please install it first."
516
+ log " WARNING " " Locust is not installed. Please install it first."
515
517
exit 1
516
518
fi
517
519
@@ -557,22 +559,58 @@ health_check() {
557
559
fi
558
560
}
559
561
562
+ # app logs
563
+ show_server_logs () {
564
+ log " Checking server logs at $FLASK_LOG_FILE ..."
565
+ log " INFO" " Press Ctrl+C to exit."
566
+ echo " "
567
+ echo " --- Server Logs ---"
568
+ echo " "
569
+ if [ -f " $FLASK_LOG_FILE " ]; then
570
+ tail -f " $FLASK_LOG_FILE "
571
+ else
572
+ log " No logs found at $FLASK_LOG_FILE ."
573
+ fi
574
+ }
575
+
560
576
561
577
# Display help
562
578
show_help () {
563
579
echo " $APP_NAME Installer"
564
- echo " Usage: ./installer.sh [options]"
580
+ echo " "
581
+ echo " Usage: $EXECUTABLE_APP_NAME [options]"
582
+ echo " "
565
583
echo " Options:"
566
- echo " --install Install $APP_NAME "
567
- echo " --uninstall Uninstall $APP_NAME "
568
- echo " --restore Restore $APP_NAME from a backup"
569
- echo " --load-test Start Locust load testing"
570
- echo " --status Check the status of $APP_NAME installation"
571
- echo " --health-check Perform a health check on localhost:5005"
572
- echo " --clean-backups Clean up all backups"
573
- echo " --help Display this help message"
584
+ echo " --install Install $APP_NAME and set up all necessary dependencies."
585
+ echo " This will configure the environment and start the application."
586
+ echo " "
587
+ echo " --uninstall Uninstall $APP_NAME completely."
588
+ echo " This will remove the application and all associated files."
589
+ echo " "
590
+ echo " --restore Restore $APP_NAME from a backup."
591
+ echo " Use this option to recover data or settings from a previous backup."
592
+ echo " "
593
+ echo " --load-test Start Locust load testing for $APP_NAME ."
594
+ echo " This will initiate performance testing to simulate multiple users."
595
+ echo " "
596
+ echo " --status Check the status of $APP_NAME installation."
597
+ echo " Displays whether $APP_NAME is installed, running, or if there are any issues."
598
+ echo " "
599
+ echo " --health-check Perform a health check on $HOST_URL ."
600
+ echo " Verifies that the application is running correctly and responding to requests."
601
+ echo " "
602
+ echo " --clean-backups Clean up all backups of $APP_NAME ."
603
+ echo " This will delete all saved backup files to free up space."
604
+ echo " "
605
+ echo " --server-logs Show server logs for $APP_NAME ."
606
+ echo " Displays the latest server logs, which can help in troubleshooting issues."
607
+ echo " Press Ctrl+C to exit the log viewing session."
608
+ echo " "
609
+ echo " --help Display this help message."
610
+ echo " Shows information about all available options and how to use them."
574
611
}
575
612
613
+
576
614
# Parse command-line options
577
615
for arg in " $@ " ; do
578
616
case $arg in
@@ -583,6 +621,7 @@ for arg in "$@"; do
583
621
--status) ACTION=" check_status" ;;
584
622
--health-check) ACTION=" health_check" ;;
585
623
--clean-backups) ACTION=" cleanup_backups" ;;
624
+ --server-logs) show_server_logs; exit 0 ;;
586
625
--help) show_help; exit 0 ;;
587
626
* ) echo " Unknown option: $arg " ; show_help; exit 1 ;;
588
627
esac
0 commit comments