Skip to content

fix: handle SIGHUP in launcher-patcher to prevent exits before updating#1641

Merged
0utplay merged 2 commits intonightlyfrom
fix/launcher-patcher-not-running
May 28, 2025
Merged

fix: handle SIGHUP in launcher-patcher to prevent exits before updating#1641
0utplay merged 2 commits intonightlyfrom
fix/launcher-patcher-not-running

Conversation

@0utplay
Copy link
Member

@0utplay 0utplay commented May 26, 2025

Motivation

The launcher-patcher tries to update the launcher.jar after the node & launcher exit. This process did not work when screen or tmux was used to start the launcher due to the fact that they send a SIGHUG signal and the JVM handles the signal and stops the still running (waiting) launcher-patcher. This required users to download the launcher themselves when we did changes to the launcher.

Modification

Introduced a handler for SIGHUP in the launcher-patcher that ignores the signal. Furthermore, this introduces a 5 second timeout when waiting for the launcher to exit before running the patcher as the launcher should not take that long to stop and to prevent replacing the next running launcher instance getting replaced while running.

Result

Launcher updates are properly working when using screen or tmux

@0utplay 0utplay added this to the 4.0.0-RC13 milestone May 26, 2025
@0utplay 0utplay requested review from Copilot and derklaro May 26, 2025 19:48
@0utplay 0utplay self-assigned this May 26, 2025
@0utplay 0utplay added v: 4.X This pull should be included in the 4.0 release t: fix A pull request introducing a fix for a bug. in: launcher An issue/pull request releated to the common launcher code labels May 26, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the launcher-patcher prematurely exits due to SIGHUP signals from terminal multiplexers like screen or tmux and ensures that the patching process continues by introducing a timeout mechanism.

  • Added a signal handler to ignore SIGHUP signals.
  • Introduced a 5-second timeout when waiting for the launcher process to terminate.
  • Replaced direct System.out.printf calls with a helper printf method for consistent logging.
Comments suppressed due to low confidence (2)

launcher/patcher/src/main/java/eu/cloudnetservice/launcher/patcher/CloudNetLauncherPatcher.java:52

  • [nitpick] Consider including the timeout value (5 seconds) in the error message to provide clearer context during troubleshooting.
printf(System.err, "Launcher process did not terminate in time, running patcher anyway");

launcher/patcher/src/main/java/eu/cloudnetservice/launcher/patcher/CloudNetLauncherPatcher.java:36

  • The code uses sun.misc.Signal from an internal API; consider verifying that this approach meets your long-term compatibility and maintainability requirements, or explore alternatives if available.
Signal.handle(new Signal("HUP"), SignalHandler.SIG_IGN);

@github-actions
Copy link

github-actions bot commented May 26, 2025

Test Results

 50 files  ±0   50 suites  ±0   1m 26s ⏱️ +2s
446 tests ±0  446 ✅ ±0  0 💤 ±0  0 ❌ ±0 
777 runs  ±0  777 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 0e910b9. ± Comparison against base commit 85defd7.

♻️ This comment has been updated with latest results.

@0utplay 0utplay merged commit e012273 into nightly May 28, 2025
5 checks passed
@0utplay 0utplay deleted the fix/launcher-patcher-not-running branch May 28, 2025 09:04
GiantTreeLP pushed a commit to GiantTreeLP/CloudNet that referenced this pull request Jun 7, 2025
…ng (CloudNetService#1641)

### Motivation
The launcher-patcher tries to update the launcher.jar after the node &
launcher exit. This process did not work when `screen` or `tmux` was
used to start the launcher due to the fact that they send a `SIGHUG`
signal and the JVM handles the signal and stops the still running
(waiting) launcher-patcher. This required users to download the launcher
themselves when we did changes to the launcher.

### Modification
Introduced a handler for `SIGHUP` in the launcher-patcher that ignores
the signal. Furthermore, this introduces a 5 second timeout when waiting
for the launcher to exit before running the patcher as the launcher
should not take that long to stop and to prevent replacing the next
running launcher instance getting replaced while running.

### Result
Launcher updates are properly working when using `screen` or `tmux`

---------

Co-authored-by: Pasqual Koschmieder <git@derklaro.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: launcher An issue/pull request releated to the common launcher code t: fix A pull request introducing a fix for a bug. v: 4.X This pull should be included in the 4.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants