davsclaus opened a new pull request, #28171:
URL: https://github.com/apache/camel/pull/28171

   https://issues.apache.org/jira/browse/CAMEL-25832
   
   Follow-up of CAMEL-25784. Before this change, `camel run` kept the log of a 
run that ended only for the default runtime. The Maven runtimes deleted the log 
when the run ended, or when the next run started. So after an app failed to 
start, `camel log <name> --previous` and the AI tools had nothing to read.
   
   ## What changes
   
   - **The log is kept when the run ends.** This covers quarkus, spring-boot 
and main, and also `camel run pom.xml` of an existing project. The `stopOnExit` 
callback keeps `<name>.log` as the previous run (`PreviousRun.keep`), where it 
used to delete it. The callback runs after the app has stopped, so the kept log 
is complete.
     - When `camel run` started the app itself (`java -jar` for main, `mvn 
camel:run` where Camel runs in the Maven JVM), the previous run has the pid and 
exit code of the app.
     - With quarkus and spring-boot, Maven runs the app in a process of its 
own. So there is no pid and no exit code of the app. When Maven fails, the 
failure says `Maven ended with exit code N`.
     - Exit codes 130, 137 and 143 are reported as the signal (SIGINT, SIGKILL, 
SIGTERM).
   - **A log left behind is kept when the next run starts.** A run that was 
killed leaves its `<name>.log`. The next run of that name now keeps it as the 
previous run, instead of deleting it (main, existing projects) or appending to 
it (quarkus). How that run ended is not known, so the time is the last write of 
the log.
   - **Spring Boot logs to `<name>.log`,** as the other runtimes do, instead of 
`<pid>.log` (the pid of the Spring Boot JVM). The readers already look for 
`<name>.log` when there is no `<pid>.log`. An existing Spring Boot project now 
gets `-Dcamel.main.name`, so the app reports the name of its log file. Existing 
Quarkus and Camel Main projects already get it.
   - The docs section "The log of the previous run" now covers all runtimes.
   
   ## Tested end to end
   
   I used a launcher built from this branch and a route that fails at startup 
(`timer:tick?period=notanumber`):
   
   | Run | Exit | Previous run |
   |---|---|---|
   | `--runtime=main` | 1 | pid of the app, exit code 1 |
   | `--runtime=main --max-seconds=8` (ok route) | 0 | pid, exit code 0, both 
log lines |
   | `--runtime=main`, CLI stopped with SIGTERM | 143 | pid, exit code 143, 
SIGTERM |
   | `--runtime=spring-boot` | 1 | `Maven ended with exit code 1`; the log has 
the startup error |
   | `--runtime=quarkus` | 1 | `Maven ended with exit code 1`; the log has the 
startup error |
   | `camel run pom.xml --runtime=spring-boot` (exported project) | 0 | while 
it ran, `camel ps` showed the name and the app wrote `<name>.log`; kept at the 
end |
   
   `camel log prevlog-boom --previous` printed "The previous run of 
prevlog-boom (pid 16017) ended at ... with exit code 1", followed by the log.
   
   One finding for a follow-up, not changed here: with `--runtime=main`, Camel 
Main does not log a startup failure. The exception leaves `main()`, and only 
the JVM prints it, to stderr. So the kept log ends before the error. Spring 
Boot ("Application run failed") and Quarkus ("Failed to start application") log 
it, so their kept logs show it.
   
   ## Tests
   
   - New `RunMavenRuntimePreviousLogTest` (8): an app's pid and exit code, the 
Maven exit code as the failure, signals, no log or no name, a log left behind, 
and the Spring Boot logback file.
   - `RunExistingProjectTest` and `RunExportedProjectTest` are updated: the log 
left behind is kept, and Spring Boot gets `<name>.log` and `-Dcamel.main.name`. 
The tests of the default runtime (`RunPreviousLogTest`, `PreviousRunTest`) pass.
   - All tests of camel-jbang-core pass (2364 + 237, before the new test class 
got its own name; the five classes for the run logs pass after).
   
   _Claude Code on behalf of davsclaus_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m


-- 
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]

Reply via email to