Skip to content

Commit

Permalink
Add the debug option and verbose (foreground) (#1949)
Browse files Browse the repository at this point in the history
* Add the debug option and verbose (foreground)

I am proposing this PR, so we can debug and do foreground run (or start?) easily. I took "suspend" and "verbose" names from some other projects, so I think the user is familiar with it.

* Update start.sh

Adding --run option to start in background with a wait

* Update run.sh

Make sure all options in start.sh also apply when using run.sh

* Update start.sh

Touch the pid before the command, since there is some loop looking for it in the cmd, and the pid is otherwise created after it. We get a race here.

* Update server/src/main/zip/bin/run.sh

Co-authored-by: Thiago Henrique Hüpner <thihup@gmail.com>
Co-authored-by: Arjan Tijms <arjan.tijms@gmail.com>
  • Loading branch information
3 people authored Oct 8, 2021
1 parent ac6147b commit 2342d13
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
22 changes: 1 addition & 21 deletions server/src/main/zip/bin/run.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
#!/bin/bash

cd ..

if [ -z ${JAVA_HOME} ]; then
echo Using default java
JAVA_BIN=java
else
echo Using JAVA_HOME: ${JAVA_HOME}
JAVA_BIN=${JAVA_HOME}/bin/java
fi

if [[ "${PIRANHA_JPMS}" == "true" ]]; then
INIT_OPTIONS="--module-path lib -m cloud.piranha.server"
else
INIT_OPTIONS="-jar lib/piranha-server.jar"
fi

exec ${JAVA_BIN} ${JAVA_ARGS} -Djava.util.logging.config.file=etc/logging.properties ${INIT_OPTIONS} &

PID=$!
echo $PID >> tmp/piranha.pid
wait $PID
exec ./start.sh --run $*
30 changes: 26 additions & 4 deletions server/src/main/zip/bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd ..

if [ -z ${JAVA_HOME} ]; then
echo Using default java
JAVA_BIN=java
JAVA_BIN=java
else
echo Using JAVA_HOME: ${JAVA_HOME}
JAVA_BIN=${JAVA_HOME}/bin/java
Expand All @@ -16,6 +16,12 @@ else
INIT_OPTIONS="-jar lib/piranha-server.jar"
fi


if [[ "$*" == *"--suspend"* ]]; then
JAVA_ARGS="${JAVA_ARGS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:9009"
fi


#
# Turn SSL on.
#
Expand All @@ -36,8 +42,24 @@ fi
#
# SSL_KEY_STORE_PASSWORD=-Djavax.net.ssl.keyStorePassword=password

${JAVA_BIN} ${JAVA_ARGS} ${SSL_DEBUG} ${SSL_KEY_STORE} ${SSL_KEY_STORE_PASSWORD} \
CMD="${JAVA_BIN} ${JAVA_ARGS} ${SSL_DEBUG} ${SSL_KEY_STORE} ${SSL_KEY_STORE_PASSWORD} \
-Djava.util.logging.config.file=etc/logging.properties \
${INIT_OPTIONS} ${SSL_ON} &
${INIT_OPTIONS} ${SSL_ON}"

echo $! >> tmp/piranha.pid
echo Starting Piranha using command: ${CMD}

touch tmp/piranha.pid

if [[ "$*" == *"--verbose"* ]]; then
${CMD}
else
if [[ "$*" == *"--run"* ]]; then
exec ${CMD} &
PID=$!
echo $PID >> tmp/piranha.pid
wait $PID
else
${CMD} &
echo $! >> tmp/piranha.pid
fi
fi

0 comments on commit 2342d13

Please sign in to comment.