Skip to content

Implement graceful shutdown support#69

Open
AxenoDev wants to merge 3 commits intoQuozul:masterfrom
AxenoDev:fix/stop-cleanly
Open

Implement graceful shutdown support#69
AxenoDev wants to merge 3 commits intoQuozul:masterfrom
AxenoDev:fix/stop-cleanly

Conversation

@AxenoDev
Copy link
Copy Markdown
Contributor

@AxenoDev AxenoDev commented Apr 5, 2026

This PR adds graceful shutdown support to the Java wrapper integration.

To fix this issues -> #58


private final Path configurationPath;
private volatile Standalone.RustLib lib;
private volatile boolean running = false;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

What are volatile properties and why are they needed here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

volatile ensures cross-thread visibility, reads/write are done against main memory
PicoLimboRunner#run() and
PicoLimboRunner#stop() are called from different threads

running = true;

String[] args = {
"pico_limbo_java_wrapper",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why did you have to add pico_limbo_java_wrapper here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uh, idk, it wasn't intended

Comment thread pico_limbo/src/lib.rs
use std::sync::OnceLock;
use tokio_util::sync::CancellationToken;

static CANCEL_TOKEN: OnceLock<CancellationToken> = OnceLock::new();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't really like static variables, but I think there aren't any way around it given we work with C library bindings?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I don't really know...

() = token.cancelled() => {
tracing::info!("Shutdown signal received, stopping server...");
}
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think there is a similar logic for handling SIGINT and SIGTERM signals, have you looked at how those two logic (signals and explicit cancellation) can be merged and if it is even possible?

@Quozul Quozul linked an issue Apr 11, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The plugin prevents the server from terminating.

2 participants