fix(jetty): make init.d stop actually stop and start after DB (#6) - #67
Closed
natechadwick-intsof wants to merge 1 commit into
Closed
fix(jetty): make init.d stop actually stop and start after DB (#6)#67natechadwick-intsof wants to merge 1 commit into
natechadwick-intsof wants to merge 1 commit into
Conversation
The SysV / init.d service for Percussion CMS on Linux 8.1.7 had two
field failures, both fixed in this commit.
1) 'service <name> stop' / '/etc/init.d/<name> stop' did not actually
stop the Jetty JVM. Two bugs in rxjetty.sh:
- The start-stop-daemon guard checked '$UID -eq 2' (the 'daemon'
account), so the start-stop-daemon branch was effectively dead
code; stop fell through to a PID-file-only 'kill' path.
- The start-stop-daemon -K signal was SIGHUP, which Java does not
treat as a stop signal. Even when the branch did fire it
signalled the wrong intent.
The stop path now resolves the actual Java/Jetty PID via a new
find_jetty_pid helper that tolerates stale, missing, or wrong
PID files by scanning /proc/*/cmdline for a Java process whose
-Djetty.base matches JETTY_BASE. It then signals SIGTERM
(default for start-stop-daemon -K) and escalates to SIGKILL
after STOP_TIMEOUT (default 60s), and re-verifies the JVM is
gone before exiting 0. A second 'service <name> stop' on an
already-stopped service is now idempotent.
2) The init.d service started before MySQL/MariaDB on reboot.
The shipped LSB header only declared '$local_fs $network' and
the chkconfig priority was '20 80' (start very early).
The header now declares 'Required-Start: $local_fs $network
$remote_fs' and 'Should-Start: $named mysqld mysql mariadb',
and the chkconfig line is raised to '2345 99 01' so the CMS
starts as one of the last services. install-jetty-service.sh
now registers update-rc.d with explicit 'start 99 2 3 4 5 .
stop 01 0 1 6 .' (and K01 on the Solaris fallback) so SysV
systems without chkconfig get the same ordering.
3) For installs with a remote DB (e.g. AWS RDS) where there is no
local mysqld init script to order against, rxjetty.sh now
exposes WAIT_FOR_DB_HOST / WAIT_FOR_DB_PORT /
WAIT_FOR_DB_TIMEOUT / WAIT_FOR_DB_INTERVAL. When
WAIT_FOR_DB_HOST is set, the start path probes host:port with
'nc -z' (bash /dev/tcp fallback) until the timeout elapses
before launching Jetty. install-jetty-service.sh ships these
vars (empty by default) in the /etc/default/<service> template
and prints a post-install hint about configuring them.
Fixes #6
Collaborator
Author
|
Closing this PR — its base (the local A new branch is being opened from the current |
natechadwick-intsof
added a commit
that referenced
this pull request
Aug 25, 2026
The SysV / init.d service for Percussion CMS on Linux had two field
failures, both fixed in this commit.
1) 'service <name> stop' / '/etc/init.d/<name> stop' did not actually
stop the Jetty JVM. Two bugs in rxjetty.sh:
- The start-stop-daemon guard checked '$UID -eq 2' (the 'daemon'
account), so the start-stop-daemon branch was effectively dead
code; stop fell through to a PID-file-only 'kill' path.
- The start-stop-daemon -K signal was SIGHUP, which Java does not
treat as a stop signal. Even when the branch did fire it
signalled the wrong intent.
The stop path now resolves the actual Java/Jetty PID via a new
find_jetty_pid helper that tolerates stale, missing, or wrong
PID files by scanning /proc/*/cmdline for a Java process whose
-Djetty.base matches JETTY_BASE. It then signals SIGTERM
(default for start-stop-daemon -K) and escalates to SIGKILL
after STOP_TIMEOUT (default 60s), and re-verifies the JVM is
gone before exiting 0. A second 'service <name> stop' on an
already-stopped service is now idempotent.
2) The init.d service started before MySQL/MariaDB on reboot.
The shipped LSB header only declared '$local_fs $network' and
the chkconfig priority was '20 80' (start very early).
The header now declares 'Required-Start: $local_fs $network
$remote_fs' and 'Should-Start: $named mysqld mysql mariadb',
and the chkconfig line is raised to '2345 99 01' so the CMS
starts as one of the last services. install-jetty-service.sh
now registers update-rc.d with explicit 'start 99 2 3 4 5 .
stop 01 0 1 6 .' (and K01 on the Solaris fallback) so SysV
systems without chkconfig get the same ordering.
3) For installs with a remote DB (e.g. AWS RDS) where there is no
local mysqld init script to order against, rxjetty.sh now
exposes WAIT_FOR_DB_HOST / WAIT_FOR_DB_PORT /
WAIT_FOR_DB_TIMEOUT / WAIT_FOR_DB_INTERVAL. When
WAIT_FOR_DB_HOST is set, the start path probes host:port with
'nc -z' (bash /dev/tcp fallback) until the timeout elapses
before launching Jetty. install-jetty-service.sh ships these
vars (empty by default) in the /etc/default/<service> template
and prints a post-install hint about configuring them.
Note: a root CHANGELOG.md entry was in the first iteration of this
fix (PR #67) but is not included here because main does not have
a root CHANGELOG.md.
Fixes #6
8 tasks
vijaya-boddipudi
pushed a commit
that referenced
this pull request
Aug 26, 2026
The SysV / init.d service for Percussion CMS on Linux had two field
failures, both fixed in this commit.
1) 'service <name> stop' / '/etc/init.d/<name> stop' did not actually
stop the Jetty JVM. Two bugs in rxjetty.sh:
- The start-stop-daemon guard checked '$UID -eq 2' (the 'daemon'
account), so the start-stop-daemon branch was effectively dead
code; stop fell through to a PID-file-only 'kill' path.
- The start-stop-daemon -K signal was SIGHUP, which Java does not
treat as a stop signal. Even when the branch did fire it
signalled the wrong intent.
The stop path now resolves the actual Java/Jetty PID via a new
find_jetty_pid helper that tolerates stale, missing, or wrong
PID files by scanning /proc/*/cmdline for a Java process whose
-Djetty.base matches JETTY_BASE. It then signals SIGTERM
(default for start-stop-daemon -K) and escalates to SIGKILL
after STOP_TIMEOUT (default 60s), and re-verifies the JVM is
gone before exiting 0. A second 'service <name> stop' on an
already-stopped service is now idempotent.
2) The init.d service started before MySQL/MariaDB on reboot.
The shipped LSB header only declared '$local_fs $network' and
the chkconfig priority was '20 80' (start very early).
The header now declares 'Required-Start: $local_fs $network
$remote_fs' and 'Should-Start: $named mysqld mysql mariadb',
and the chkconfig line is raised to '2345 99 01' so the CMS
starts as one of the last services. install-jetty-service.sh
now registers update-rc.d with explicit 'start 99 2 3 4 5 .
stop 01 0 1 6 .' (and K01 on the Solaris fallback) so SysV
systems without chkconfig get the same ordering.
3) For installs with a remote DB (e.g. AWS RDS) where there is no
local mysqld init script to order against, rxjetty.sh now
exposes WAIT_FOR_DB_HOST / WAIT_FOR_DB_PORT /
WAIT_FOR_DB_TIMEOUT / WAIT_FOR_DB_INTERVAL. When
WAIT_FOR_DB_HOST is set, the start path probes host:port with
'nc -z' (bash /dev/tcp fallback) until the timeout elapses
before launching Jetty. install-jetty-service.sh ships these
vars (empty by default) in the /etc/default/<service> template
and prints a post-install hint about configuring them.
Note: a root CHANGELOG.md entry was in the first iteration of this
fix (PR #67) but is not included here because main does not have
a root CHANGELOG.md.
Fixes #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the two Linux 8.1.7 SysV / init.d field failures from #6:
service <name> stop//etc/init.d/<name> stopdid not actually stopthe Jetty JVM.
reachable.
Problem 1 — stop did not stop
Two bugs in
system/Tools/jetty/defaults/bin/rxjetty.sh:start-stop-daemonguard checked$UID -eq 2(thedaemonaccount), so the
start-stop-daemonbranch was effectively dead code.Stop always fell through to a PID-file-only
killpath.start-stop-daemon -Ksignal wasSIGHUP, which Java does nottreat as a stop signal. Even when the branch did fire it signalled the
wrong intent.
The stop path now:
find_jetty_pidhelperthat tolerates stale, missing, or wrong PID files by scanning
/proc/*/cmdlinefor a Java process whose-Djetty.basematchesJETTY_BASE(the same recovery pattern thatStopJetty.shalreadyused).
SIGTERM(the default forstart-stop-daemon -K) andescalates to
SIGKILLafterSTOP_TIMEOUT(default 60s).service <name> stopon an already-stopped service is nowidempotent rather than failing.
Problem 2 — starts before DB on reboot
$local_fs $networkand thechkconfig priority was
20 80(start very early). The header nowdeclares
Required-Start: $local_fs $network $remote_fsandShould-Start: $named mysqld mysql mariadb, and the chkconfig lineis raised to
2345 99 01so the CMS starts as one of the lastservices on boot.
install-jetty-service.shnow registersupdate-rc.dwith explicitstart 99 2 3 4 5 . stop 01 0 1 6 .(andK01on the Solarisfallback) so SysV systems without chkconfig get the same ordering.
mysqldinit script to order against,rxjetty.shnow exposesWAIT_FOR_DB_HOST/WAIT_FOR_DB_PORT/WAIT_FOR_DB_TIMEOUT/WAIT_FOR_DB_INTERVAL. WhenWAIT_FOR_DB_HOSTis set, the startpath probes
host:portwithnc -z(bash/dev/tcpfallback) untilthe timeout elapses before launching Jetty.
install-jetty-service.shships these vars (empty by default) in the
/etc/default/<service>template and prints a post-install hint about configuring them.
Acceptance from #6
service <name> stopand/etc/init.d/<name> stopleave noCMS/Jetty JVM.
service <name> startafter stop starts cleanly.service <name> restartworks end-to-end./procscan; never exits 0while Jetty still runs.
manual start (via LSB
Should-Start+ chkconfig99 01).WAIT_FOR_DB_HOSTfor first bootafter reboot.
(post-install hint).
no local
mysqldinit script.Verification
bash -nclean on all three modified files.produces zero new warnings (the only warnings the linter raises are
pre-existing issues in unrelated lines).
find_jetty_pidreturns the live PID when the PID file is correct,recovers from a stale PID via the
/procscan, removes the stalePID file, and returns failure cleanly when nothing matches.
wait_for_dbis a no-op whenWAIT_FOR_DB_HOSTis unset, succeedson a reachable port, fails on a closed port, and is disabled by
WAIT_FOR_DB_TIMEOUT=0.stop_pidkills a cooperative process, no-ops on a dead PID, andescalates
TERM→KILLwithin ~3s on aSIGTERM-ignoringprocess, confirming the process is dead before returning 0.
Notes
rxjetty.shblob exists onmain(sameshaasdevelopment-8.1.x), so this branch targetsmainfor the merge toactually fix the issue. Base is a clean ancestor of
main.buildNumberinVersion.propertiesis not bumped here, perAGENTS.mdthe post-merge workflow handles that.target/copies ofrxjetty.share build artifacts; they regeneratefrom
system/Tools/jetty/during theperc-jettyMaven assembly.Files changed
Fixes #6