Skip to content

Commit

Permalink
added debug flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyaven committed Jan 14, 2024
1 parent 4c2bc7e commit 9f0041c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ ENV POSTGRES_USER=stackql
ENV POSTGRES_PASSWORD=stackql
ENV POSTGRES_DB=stackql

# Environment variable to toggle DEBUG mode
ENV DEBUG=false

# Environment variable to toggle SECURE_MODE
ENV SECURE_MODE=false

Expand Down
15 changes: 12 additions & 3 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,34 @@ check_certs_and_keys() {

# Function to start StackQL with or without mTLS
start_stackql() {
# Initialize debug arguments
local debug_args=""

# Check if DEBUG mode is enabled
if [ "$DEBUG" = "true" ]; then
debug_args="--loglevel=debug --pgsrv.loglevel=DEBUG"
fi

if [ "$SECURE_MODE" = "true" ]; then
echo "Running with mTLS..."
set_cert_dir
check_certs_and_keys
CLIENT_CA_ENCODED=$(base64 -w 0 "$CERT_DIR/client_cert.pem")
# Start the server with TLS configuration
# Start the server with TLS configuration and potentially debug arguments
/srv/stackql/stackql srv --approot=/srv/stackql/.stackql \
--pgsrv.port=$PGSRV_PORT \
--sqlBackend="{\"dbEngine\": \"postgres_tcp\", \"sqlDialect\": \"postgres\", \"dsn\": \"postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}\"}" \
--pgsrv.tls="{ \
\"keyFilePath\": \"$CERT_DIR/server_key.pem\", \
\"certFilePath\": \"$CERT_DIR/server_cert.pem\", \
\"clientCAs\": [\"$CLIENT_CA_ENCODED\"] \
}"
}" $debug_args
else
echo "Running without mTLS..."
# Start the server without TLS configuration but with potentially debug arguments
/srv/stackql/stackql srv --approot=/srv/stackql/.stackql \
--pgsrv.port=$PGSRV_PORT \
--sqlBackend="{\"dbEngine\": \"postgres_tcp\", \"sqlDialect\": \"postgres\", \"dsn\": \"postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}\"}"
--sqlBackend="{\"dbEngine\": \"postgres_tcp\", \"sqlDialect\": \"postgres\", \"dsn\": \"postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}\"}" $debug_args
fi
}

Expand Down

0 comments on commit 9f0041c

Please sign in to comment.