davsclaus opened a new pull request, #29823: URL: https://github.com/apache/camel/pull/29823
## Summary Item 8 of [CAMEL-26912](https://issues.apache.org/jira/browse/CAMEL-26912): **the directories of runs were left behind, or removed under other runs.** `camel run --runtime=camel-main|spring-boot|quarkus` exports the project to `.camel-jbang-run/<millis>`, builds it there and runs it. The directory (with the project and its `target/`, the application JAR) is only removed by the shutdown hook of the Camel CLI: - a run that is killed (`kill -9`, the terminal closed, a crash) leaves it behind for good, one more for each such run - `camel debug` (Spring Boot, Quarkus) builds its own `camel-jbang-debug-pom.xml` and has no run directory, but removed the whole `.camel-jbang-run` when it ended: the directories of the other runs in the directory, which were still running ### Fix - A run directory has a hidden `.camel-run-pid` file with the pid of the Camel CLI that runs it (hidden, as the project is exported to that directory). - `ProjectRunner.createRunDir()` creates it, for the three runners, and first removes the run directories whose process is gone (`removeStaleRunDirs`). - `camel debug` removes only those, not the directories of runs that are running. - A run directory without the file (of an earlier Camel version) is kept: it may still be running. A pid reused by another process keeps a stale directory until that process ends, which is harmless. With the unpacked launcher and the new camel-jbang-run jar, in a directory with `.camel-jbang-run/1000` (the pid of an ended process, with a `target/`) and `.camel-jbang-run/999` (no pid): `camel run a.camel.yaml --runtime=camel-main --max-seconds=8` removes `1000` when it starts, runs in a new directory with its pid, keeps `999`, and removes its own directory when it ends. ## Tests - `ProjectRunnerTest.removesTheDirectoriesOfRunsWhoseProcessIsGone`: the directory of an ended process is removed; those of this process and without a pid are kept. - `ProjectRunnerTest.aCamelMainRunExportsAndBuildsTheProjectAndStartsItsJar` checks the pid of the run directory. - The golden files of the runs with a Maven runtime (`maven-*.maven.txt`) list `.camel-run-pid` among the files of the run directory (6 files, one line each). - camel-jbang-run (271 tests), camel-jbang-core including `RunExportGoldenTest`, and camel-jbang-plugin-kubernetes (156 tests) pass locally. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
