generated from oci/template
All checks were successful
Build Docker Image on Commit / build-and-publish (push) Successful in 16m30s
68 lines
1.8 KiB
Bash
Executable file
68 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
# Function to log messages with timestamp
|
|
log() {
|
|
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
|
|
}
|
|
|
|
# Function to handle signals for graceful shutdown
|
|
cleanup() {
|
|
log "Received shutdown signal, stopping FreeTAKServer..."
|
|
if [ -n "$FTS_PID" ]; then
|
|
kill -TERM "$FTS_PID" 2>/dev/null || true
|
|
wait "$FTS_PID" 2>/dev/null || true
|
|
fi
|
|
log "FreeTAKServer stopped"
|
|
exit 0
|
|
}
|
|
|
|
# Set up signal handlers
|
|
trap cleanup SIGTERM SIGINT
|
|
|
|
# Source the virtual environment
|
|
log "Activating Python virtual environment..."
|
|
source ${FTS_VENV}/bin/activate
|
|
|
|
# Set up environment variables based on install type
|
|
case ${INSTALL_TYPE} in
|
|
legacy)
|
|
export CFG_RPATH=controllers/configuration
|
|
log "Using legacy configuration path: ${CFG_RPATH}"
|
|
;;
|
|
*)
|
|
export CFG_RPATH=core/configuration
|
|
log "Using standard configuration path: ${CFG_RPATH}"
|
|
;;
|
|
esac
|
|
|
|
# Change to the configuration directory
|
|
CONFIG_DIR="/opt/FreeTAKHub-Installation/${CFG_RPATH}"
|
|
if [ -d "$CONFIG_DIR" ]; then
|
|
log "Changing to configuration directory: $CONFIG_DIR"
|
|
cd "$CONFIG_DIR"
|
|
else
|
|
log "WARNING: Configuration directory not found at $CONFIG_DIR"
|
|
log "Attempting to start from FreeTAKHub-Installation root..."
|
|
cd /opt/FreeTAKHub-Installation
|
|
fi
|
|
|
|
# Start FreeTAKServer
|
|
log "Starting FreeTAKServer (Install Type: ${INSTALL_TYPE})..."
|
|
log "Python version: $(python3 --version)"
|
|
log "Working directory: $(pwd)"
|
|
|
|
# Start the service in the background to allow signal handling
|
|
python3 -m FreeTAKServer.controllers.services.FTS &
|
|
FTS_PID=$!
|
|
|
|
log "FreeTAKServer started with PID: $FTS_PID"
|
|
log "FreeTAKServer is running. Use Ctrl+C to stop."
|
|
|
|
# Wait for the background process
|
|
wait "$FTS_PID"
|
|
|
|
# Deactivate virtual environment
|
|
deactivate
|
|
|
|
log "FreeTAKServer has stopped"
|