I have a Rust program that uses Aeron through the aeron-rs crate.
Every time I want to run my program, I need to manually start the driver first. In fact, the crate explicitly states that it works simply as a wrapper around the running driver.
I would like that the driver launches upon starting my program.
I know that Aeron provides an embedded driver, but I'm clueless about how to possibly integrate it.
So far, I've put the embedded driver JAR in my src folder
my-project/
src/
aeron-all-1.32.0-SNAPSHOT.jar
I used the include_bytes!
macro to try to include the JAR in the build
fn main() {
include_bytes!("aeron-all-1.32.0-SNAPSHOT.jar");
}
I don't see the jar in the build folder.
Then, the following code should run the driver upon startup:
if cfg!(target_os = "windows") {
Command::new("cmd")
.args(&[
"/C",
"%JAVA_HOME%\\bin\\java \
-cp aeron-all-1.32.0-SNAPSHOT.jar \
%JVM_OPTS% io.aeron.driver.MediaDriver %*",
])
.output()
.expect("Failed to execute external process.")
} else {
Command::new("sh")
.arg("-c")
.arg(
"${JAVA_HOME}/bin/java \
-cp aeron-all-1.32.0-SNAPSHOT.jar \
${JVM_OPTS} io.aeron.driver.MediaDriver \"$@\"",
)
.output()
.expect("Failed to execute external process.")
};
Is this the right way to run the jar file?