Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/aem-lts/bin/aem-lts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ IS_RUNNING=false
case "${action}" in
start)

${IS_RUNNING} && aem_lts_err "AEM ${service} already running"
[[ -f "${PID_FILE}" ]] && sudo rm -f "${PID_FILE}" # remove stale pid file if present
if ! ${INTERACTIVE}; then
${IS_RUNNING} && aem_lts_err "AEM ${service} already running"
[[ -f "${PID_FILE}" ]] && sudo rm -f "${PID_FILE}" # remove stale pid file if present
fi

port=$(get_runmode_port ${service})
jvm_opts="-agentlib:jdwp=transport=dt_socket,address=*:3${port},server=y,suspend=n"
Expand All @@ -89,7 +91,7 @@ case "${action}" in
if ${INTERACTIVE}; then
# run in foreground; CTRL+C to stop
echo "Running in interactive mode, press CTRL+C to stop..."
${JAVA_HOME}/bin/java ${jvm_opts} -jar "${jarFileLink}" ${cq_opts}
sudo sh -c "cd '$(dirname "${jarFileLink}")' && exec ${JAVA_HOME}/bin/java ${jvm_opts} -jar '${jarFileLink}' ${cq_opts}"
else
sudo start-stop-daemon --start --quiet --background --chuid root \
--make-pidfile --pidfile "${PID_FILE}" \
Expand Down
2 changes: 1 addition & 1 deletion src/aem-lts/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "aem-lts",
"version": "1.2.0",
"version": "1.2.1",
"name": "Adobe Experience Manager LTS",
"description": "Setup author and publish services. Requires the AEM LTS quickstart jar and license details.",
"options": {
Expand Down
29 changes: 19 additions & 10 deletions test/aem-lts/defaults-with-quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,27 @@ test_runmode() {
check "${service}: no java process should be running" \
[ -z $(pgrep -x java) ]

# Test interactive mode: start in background, capture stdout, verify process runs, then kill it
INTERACTIVE_LOG=$(mktemp)
aem-lts start ${service} -i > ${INTERACTIVE_LOG} &
INTERACTIVE_PID=$!
check "${service}: interactive mode wait for server started on port ${port}" \
timeout 10 bash -c "until grep -q 'Server started on port ${port}' ${INTERACTIVE_LOG} 2>/dev/null; do sleep 0.5; done"
check "${service}: interactive mode pid matches java process" \
[ $(pgrep -P ${INTERACTIVE_PID} -x java) -eq $(pgrep -x java) ]
kill $(pgrep -P ${INTERACTIVE_PID} -x java) 2>/dev/null
# Test interactive mode (-i flag): verifies aem-lts starts java in the foreground.
# Since the test itself is non-interactive, we background the process with & and
# simulate a user CTRL+C by killing java and the shell wrapper explicitly.
# set +e is required because killing background jobs causes non-zero exit codes
# which would otherwise abort the test script due to set -e at the top.
set +e
aem-lts start ${service} -i &
INTERACTIVE_BG=$! # pid of the backgrounded aem-lts shell wrapper
check "${service}: interactive mode java process starts" \
timeout 10 bash -c "until pgrep -x java > /dev/null; do sleep 0.5; done"
# java runs as root via sudo sh -c, so sudo pkill is required to send the signal
# kill INTERACTIVE_BG terminates the shell wrapper after java is gone
sudo pkill -x java 2>/dev/null
kill ${INTERACTIVE_BG} 2>/dev/null
wait ${INTERACTIVE_BG} 2>/dev/null # reap the background job to avoid zombies
check "${service}: interactive mode java process stopped after kill" \
timeout 10 bash -c "until ! pgrep -x java > /dev/null; do sleep 0.5; done"
rm -f ${INTERACTIVE_LOG}
# ensures process is fully gone before returning so the next test_runmode call
# starts with a clean state
until ! pgrep -x java > /dev/null; do sleep 0.5; done
set -e
}

test_runmode author 4502
Expand Down
Loading