Merge pull request #771 from nsacyber/v3_bootRun-debug-option

V3 boot run debug option
This commit is contained in:
iadgovuser26 2024-05-15 08:02:19 -04:00 committed by GitHub
commit 53e03613e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 7 deletions

View File

@ -20,6 +20,12 @@ java {
}
}
bootRun {
if (project.hasProperty('debug')) {
jvmArgs project.debug
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor

View File

@ -14,6 +14,7 @@ SCRIPT_DIR=$( dirname -- "$( readlink -f -- "$0"; )"; )
LOG_FILE=/dev/null
GRADLE_WRAPPER="./gradlew"
DEPLOYED_WAR=false
DEBUG_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9123"
# Check for sudo or root user
if [ "$EUID" -ne 0 ]
@ -27,6 +28,7 @@ help () {
echo " options:"
echo " -p | --path Path to the HIRS_AttestationCAPortal.war file"
echo " -w | --war Use deployed war file"
echo " -d | --debug Launch the JVM with a debug port open"
echo " -h | --help Print this help"
echo
}
@ -49,6 +51,10 @@ while [[ $# -gt 0 ]]; do
WAR_PATH="/opt/hirs/aca/HIRS_AttestationCAPortal.war"
DEPLOYED_WAR=true
;;
-d|--debug)
DEBUG_ACA=YES
shift
;;
-h|--help)
help
exit 0
@ -127,11 +133,19 @@ WEB_TLS_PARAMS="--server.ssl.key-store-password=$hirs_pki_password \
if [ -z "$USE_WAR" ]; then
echo "Booting the ACA from local build..."
# ./gradlew bootRun --args="$CONNECTOR_PARAMS$WEB_TLS_PARAMS"
./gradlew bootRun --args="--spring.config.location=$SPRING_PROP_FILE"
if [ "$DEBUG_ACA" == YES ]; then
echo "... in debug"
./gradlew bootRun --args="--spring.config.location=$SPRING_PROP_FILE" -Pdebug="$DEBUG_OPTIONS"
else
./gradlew bootRun --args="--spring.config.location=$SPRING_PROP_FILE"
fi
else
echo "Booting the ACA from a war file..."
# java -jar $WAR_PATH $CONNECTOR_PARAMS$WEB_TLS_PARAMS &
java -jar $WAR_PATH --spring.config.location=$SPRING_PROP_FILE &
exit 0
if [ "$DEBUG_ACA" == YES ]; then
echo "... in debug"
java $DEBUG_OPTIONS -jar $WAR_PATH --spring.config.location=$SPRING_PROP_FILE &
else
java -jar $WAR_PATH --spring.config.location=$SPRING_PROP_FILE &
fi
exit 0
fi

View File

@ -1,6 +1,7 @@
param (
[string]$p, [string]$path = $null,
[switch]$w, [switch]$war = $false,
[switch]$d, [switch]$debug = $false,
[switch]$h, [switch]$help = $false
)
@ -9,6 +10,7 @@ $ACA_COMMON_SCRIPT=(Join-Path $APP_HOME 'aca_common.ps1')
$ALG="RSA" # or "ECC"
$GRADLE_WRAPPER='./gradlew'
$DEPLOYED_WAR=$null
$DEBUG_OPTIONS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9123'
# Load other scripts
. $ACA_COMMON_SCRIPT
@ -34,6 +36,7 @@ if ($p) {
$path = $p
}
$war = $w -or $war
$debug = $d -or $debug
$help = $h -or $help
if(!(New-Object Security.Principal.WindowsPrincipal(
@ -49,6 +52,7 @@ if ($help) {
echo " options:"
echo " -p | --path Path to the HIRS_AttestationCAPortal.war file"
echo " -w | --war Use deployed war file"
echo " -d | --debug Launch the JVM with a debug port open"
echo " -h | --help Print this help"
exit 1
}
@ -73,8 +77,19 @@ if (!$DEPLOYED_WAR) {
$SPRING_PROP_FILE_FORWARDSLASHES=($global:HIRS_DATA_SPRING_PROP_FILE | ChangeBackslashToForwardSlash)
if ($w -or $war) {
echo "Booting the ACA from a war file..." | WriteAndLog
java -jar $DEPLOYED_WAR --spring.config.location=$SPRING_PROP_FILE_FORWARDSLASHES
if ($d -or $debug) {
echo "... in debug"
java $DEBUG_OPTIONS -jar $DEPLOYED_WAR --spring.config.location=$SPRING_PROP_FILE_FORWARDSLASHES
} else {
java -jar $DEPLOYED_WAR --spring.config.location=$SPRING_PROP_FILE_FORWARDSLASHES
}
} else {
echo "Booting the ACA from local build..." | WriteAndLog
./gradlew bootRun --args="--spring.config.location=$SPRING_PROP_FILE_FORWARDSLASHES"
if ($d -or $debug) {
echo "... in debug"
./gradlew bootRun --args="--spring.config.location=$SPRING_PROP_FILE_FORWARDSLASHES" -Pdebug="$$DEBUG_OPTIONS"
} else {
./gradlew bootRun --args="--spring.config.location=$SPRING_PROP_FILE_FORWARDSLASHES"
}
}